• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IXmlDocument类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IXmlDocument的典型用法代码示例。如果您正苦于以下问题:C# IXmlDocument类的具体用法?C# IXmlDocument怎么用?C# IXmlDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IXmlDocument类属于命名空间,在下文中一共展示了IXmlDocument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SetNodeValueString

        static void SetNodeValueString(string str, IXmlDocument xmldoc, IXmlNode node) {
            IXmlText textNode;
            int res = xmldoc.CreateTextNode(str, out textNode);
            ComFunctions.CheckHRESULT(res);

            IXmlNode textNodeAsNode = (IXmlNode)textNode;
            IXmlNode appendedChild;
            res = node.AppendChild(textNodeAsNode, out appendedChild);
            ComFunctions.CheckHRESULT(res);
        }
开发者ID:JustGitHubUser,项目名称:DevExpress.Mvvm.Free,代码行数:10,代码来源:ToastNotificationContent.cs


示例2: XmlDocumentLoader

        public XmlDocumentLoader(IXmlDocument document)
        {
            if (document == null)
                throw new ArgumentNullException(nameof(document));
            Document = document;

            XmlReaderSettings = new XmlReaderSettings();
            XmlReaderSettings.DtdProcessing = DtdProcessing.Parse;

            XmlWriterSettings = new XmlWriterSettings();
            XmlWriterSettings.Indent = true;
        }
开发者ID:LazyTarget,项目名称:Lux,代码行数:12,代码来源:XmlDocumentLoader.cs


示例3: SetImageSrc

        static void SetImageSrc(IXmlDocument xmldoc, string imagePath) {
            IXmlNodeList nodes;
            int res = xmldoc.GetElementsByTagName("image", out nodes);
            ComFunctions.CheckHRESULT(res);

            IXmlNode imageNode;
            res = nodes.Item(0, out imageNode);
            ComFunctions.CheckHRESULT(res);

            IXmlNode srcAttribute;
            res = imageNode.Attributes.GetNamedItem("src", out srcAttribute);
            ComFunctions.CheckHRESULT(res);

            SetNodeValueString(imagePath, xmldoc, srcAttribute);
        }
开发者ID:JustGitHubUser,项目名称:DevExpress.Mvvm.Free,代码行数:15,代码来源:ToastNotificationContent.cs


示例4: ParseDom

 private void ParseDom(IXmlDocument dom)
 {
     var root = dom.DocumentElement;
     if (root == null) return;
     switch (root.LocalName)
     {
         case "score-partwise":
             ParsePartwise(root);
             break;
         case "score-timewise":
             //ParseTimewise(root);
             break;
         default:
             throw new UnsupportedFormatException();
     }
 }
开发者ID:eriser,项目名称:alphaTab,代码行数:16,代码来源:MusicXml2Importer.cs


示例5: Save

        public virtual bool Save(IXmlDocument document, Stream stream)
        {
            if (!stream.CanWrite)
                throw new NotSupportedException("The stream cannot be written to");
            try
            {
                var xdoc = LoadXDocument(stream);

                using (var xmlWriter = XmlWriter.Create(stream, XmlWriterSettings))
                {
                    Document.Export(xdoc);
                    xdoc.Save(xmlWriter);
                }
                return true;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
开发者ID:LazyTarget,项目名称:Lux,代码行数:20,代码来源:XmlDocumentLoader.cs


示例6: ParseDom

        private void ParseDom(IXmlDocument dom)
        {
            var root = dom.DocumentElement;
            if (root == null) return;

            // the XML uses IDs for referring elements within the
            // model. Therefore we do the parsing in 2 steps:
            // - at first we read all model elements and store them by ID in a lookup table
            // - after that we need to join up the information.
            if (root.LocalName == "GPIF")
            {
                Score = new Score();

                // parse all children
                root.IterateChildren(n =>
                {
                    if (n.NodeType == XmlNodeType.Element)
                    {
                        switch (n.LocalName)
                        {
                            case "Score":
                                ParseScoreNode(n);
                                break;
                            case "MasterTrack":
                                ParseMasterTrackNode(n);
                                break;
                            case "Tracks":
                                ParseTracksNode(n);
                                break;
                            case "MasterBars":
                                ParseMasterBarsNode(n);
                                break;
                            case "Bars":
                                ParseBars(n);
                                break;
                            case "Voices":
                                ParseVoices(n);
                                break;
                            case "Beats":
                                ParseBeats(n);
                                break;
                            case "Notes":
                                ParseNotes(n);
                                break;
                            case "Rhythms":
                                ParseRhythms(n);
                                break;
                        }
                    }
                });
            }
            else
            {
                throw new UnsupportedFormatException();
            }

            BuildModel();
        }
开发者ID:rkenning,项目名称:alphaTab,代码行数:58,代码来源:GpxParser.cs


示例7: CreateDocumentType

        private void CreateDocumentType(JsonReader reader, IXmlDocument document, IXmlNode currentNode)
        {
            string name = null;
            string publicId = null;
            string systemId = null;
            string internalSubset = null;
            while (reader.Read() && reader.TokenType != JsonToken.EndObject)
            {
                switch (reader.Value.ToString())
                {
                    case "@name":
                        reader.Read();
                        name = reader.Value.ToString();
                        break;
                    case "@public":
                        reader.Read();
                        publicId = reader.Value.ToString();
                        break;
                    case "@system":
                        reader.Read();
                        systemId = reader.Value.ToString();
                        break;
                    case "@internalSubset":
                        reader.Read();
                        internalSubset = reader.Value.ToString();
                        break;
                    default:
                        throw new JsonSerializationException("Unexpected property name encountered while deserializing XmlDeclaration: " + reader.Value);
                }
            }

            IXmlNode documentType = document.CreateXmlDocumentType(name, publicId, systemId, internalSubset);
            currentNode.AppendChild(documentType);
        }
开发者ID:Henry-T,项目名称:UnityPG,代码行数:34,代码来源:XmlNodeConverter.cs


示例8: CreateElement

 private IXmlElement CreateElement(string elementName, IXmlDocument document, string elementPrefix, XmlNamespaceManager manager)
 {
   return (!string.IsNullOrEmpty(elementPrefix))
            ? document.CreateElement(elementName, manager.LookupNamespace(elementPrefix))
            : document.CreateElement(elementName);
 }
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:6,代码来源:XmlNodeConverter.cs


示例9: AddAttribute

        private static void AddAttribute(JsonReader reader, IXmlDocument document, IXmlNode currentNode, string attributeName, XmlNamespaceManager manager, string attributePrefix)
        {
            string attributeValue = reader.Value.ToString();

            IXmlNode attribute = (!string.IsNullOrEmpty(attributePrefix))
                ? document.CreateAttribute(attributeName, manager.LookupNamespace(attributePrefix), attributeValue)
                : document.CreateAttribute(attributeName, attributeValue);

            ((IXmlElement) currentNode).SetAttributeNode(attribute);
        }
开发者ID:b-bot-110,项目名称:Newtonsoft.Json,代码行数:10,代码来源:XmlNodeConverter.cs


示例10: AddJsonArrayAttribute

 private void AddJsonArrayAttribute(IXmlElement element, IXmlDocument document)
 {
   element.SetAttributeNode(document.CreateAttribute("json:Array", JsonNamespaceUri, "true"));
 }
开发者ID:argul,项目名称:tri_battle,代码行数:4,代码来源:XmlNodeConverter.cs


示例11: ReadElement

    private void ReadElement(JsonReader reader, IXmlDocument document, IXmlNode currentNode, string propertyName, XmlNamespaceManager manager)
    {
      if (string.IsNullOrEmpty(propertyName))
        throw new JsonSerializationException("XmlNodeConverter cannot convert JSON with an empty property name to XML.");

      Dictionary<string, string> attributeNameValues = ReadAttributeElements(reader, manager);

      string elementPrefix = MiscellaneousUtils.GetPrefix(propertyName);

      if (propertyName.StartsWith("@"))
      {
        var attributeName = propertyName.Substring(1);
        var attributeValue = reader.Value.ToString();

        var attributePrefix = MiscellaneousUtils.GetPrefix(attributeName);

        var attribute = (!string.IsNullOrEmpty(attributePrefix))
                                 ? document.CreateAttribute(attributeName, manager.LookupNamespace(attributePrefix), attributeValue)
                                 : document.CreateAttribute(attributeName, attributeValue);

        ((IXmlElement)currentNode).SetAttributeNode(attribute);
      }
      else
      {
        IXmlElement element = CreateElement(propertyName, document, elementPrefix, manager);

        currentNode.AppendChild(element);

        // add attributes to newly created element
        foreach (KeyValuePair<string, string> nameValue in attributeNameValues)
        {
          string attributePrefix = MiscellaneousUtils.GetPrefix(nameValue.Key);

          IXmlNode attribute = (!string.IsNullOrEmpty(attributePrefix))
                                 ? document.CreateAttribute(nameValue.Key, manager.LookupNamespace(attributePrefix), nameValue.Value)
                                 : document.CreateAttribute(nameValue.Key, nameValue.Value);

          element.SetAttributeNode(attribute);
        }

        if (reader.TokenType == JsonToken.String
            || reader.TokenType == JsonToken.Integer
            || reader.TokenType == JsonToken.Float
            || reader.TokenType == JsonToken.Boolean
            || reader.TokenType == JsonToken.Date)
        {
          element.AppendChild(document.CreateTextNode(ConvertTokenToXmlValue(reader)));
        }
        else if (reader.TokenType == JsonToken.Null)
        {
          // empty element. do nothing
        }
        else
        {
          // finished element will have no children to deserialize
          if (reader.TokenType != JsonToken.EndObject)
          {
            manager.PushScope();

            DeserializeNode(reader, document, manager, element);

            manager.PopScope();
          }
        }
      }
    }
开发者ID:284247028,项目名称:MvvmCross,代码行数:66,代码来源:XmlNodeConverter.cs


示例12: ReadArrayElements

        private void ReadArrayElements(JsonReader reader, IXmlDocument document, string propertyName, IXmlNode currentNode, XmlNamespaceManager manager)
        {
            string elementPrefix = MiscellaneousUtils.GetPrefix(propertyName);

              IXmlElement nestedArrayElement = CreateElement(propertyName, document, elementPrefix, manager);

              currentNode.AppendChild(nestedArrayElement);

              while (reader.Read() && reader.TokenType != JsonToken.EndArray)
              {
            DeserializeValue(reader, document, manager, propertyName, nestedArrayElement);
              }
        }
开发者ID:WuziyiaoKingIris20140501,项目名称:KFC,代码行数:13,代码来源:XmlNodeConverter.cs


示例13: ReadArrayElements

 // Token: 0x060006E6 RID: 1766
 // RVA: 0x000385A8 File Offset: 0x000367A8
 private void ReadArrayElements(JsonReader reader, IXmlDocument document, string propertyName, IXmlNode currentNode, XmlNamespaceManager manager)
 {
     string prefix = MiscellaneousUtils.GetPrefix(propertyName);
     IXmlElement xmlElement = this.CreateElement(propertyName, document, prefix, manager);
     currentNode.AppendChild(xmlElement);
     int num = 0;
     while (reader.Read())
     {
         if (reader.TokenType == JsonToken.EndArray)
         {
             break;
         }
         this.DeserializeValue(reader, document, manager, propertyName, xmlElement);
         num++;
     }
     if (this.WriteArrayAttribute)
     {
         this.AddJsonArrayAttribute(xmlElement, document);
     }
     if (num == 1 && this.WriteArrayAttribute)
     {
         IXmlElement element = Enumerable.Single<IXmlElement>(Enumerable.OfType<IXmlElement>(xmlElement.ChildNodes), (IXmlElement n) => n.LocalName == propertyName);
         this.AddJsonArrayAttribute(element, document);
     }
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:27,代码来源:XmlNodeConverter.cs


示例14: CreateElement

    private IXmlElement CreateElement(string elementName, IXmlDocument document, string elementPrefix, XmlNamespaceManager manager)
    {
      string ns = string.IsNullOrEmpty(elementPrefix) ? manager.DefaultNamespace : manager.LookupNamespace(elementPrefix);

      IXmlElement element = (!string.IsNullOrEmpty(ns)) ? document.CreateElement(elementName, ns) : document.CreateElement(elementName);

      return element;
    }
开发者ID:284247028,项目名称:MvvmCross,代码行数:8,代码来源:XmlNodeConverter.cs


示例15: SetDuration

 static void SetDuration(IXmlDocument xmldoc, NotificationDuration duration) {
     IXmlNodeList nodes;
     ComFunctions.CheckHRESULT(xmldoc.GetElementsByTagName("toast", out nodes));
     IXmlNode toastNode;
     ComFunctions.CheckHRESULT(nodes.Item(0, out toastNode));
     ((IXmlElement)toastNode).SetAttribute("duration", "long");
 }
开发者ID:JustGitHubUser,项目名称:DevExpress.Mvvm.Free,代码行数:7,代码来源:ToastNotificationContent.cs


示例16: SetSound

 static void SetSound(IXmlDocument xmldoc, PredefinedSound sound) {
     string soundXml = "ms-winsoundevent:" + sound.ToString().Replace("_", ".");
     IXmlElement soundElement;
     ComFunctions.CheckHRESULT(xmldoc.CreateElement("audio", out soundElement));
     if(sound == PredefinedSound.NoSound) {
         ComFunctions.CheckHRESULT(soundElement.SetAttribute("silent", "true"));
     }
     else {
         ComFunctions.CheckHRESULT(soundElement.SetAttribute("src", soundXml));
         ComFunctions.CheckHRESULT(soundElement.SetAttribute("loop", IsLoopingSound(sound).ToString().ToLower()));
     }
     var asNode = (IXmlNode)xmldoc;
     IXmlNode appendedChild;
     IXmlNodeList nodes;
     ComFunctions.CheckHRESULT(xmldoc.GetElementsByTagName("toast", out nodes));
     IXmlNode toastNode;
     ComFunctions.CheckHRESULT(nodes.Item(0, out toastNode));
     ComFunctions.CheckHRESULT(toastNode.AppendChild((IXmlNode)soundElement, out appendedChild));
 }
开发者ID:JustGitHubUser,项目名称:DevExpress.Mvvm.Free,代码行数:19,代码来源:ToastNotificationContent.cs


示例17: SetTextLine

 static void SetTextLine(IXmlDocument xmldoc, uint index, string text) {
     IXmlNodeList nodes;
     ComFunctions.CheckHRESULT(xmldoc.GetElementsByTagName("text", out nodes));
     Debug.Assert(nodes.Length >= index + 1);
     IXmlNode node;
     ComFunctions.CheckHRESULT(nodes.Item(index, out node));
     SetNodeValueString(text, xmldoc, node);
 }
开发者ID:JustGitHubUser,项目名称:DevExpress.Mvvm.Free,代码行数:8,代码来源:ToastNotificationContent.cs


示例18: ReadElement

 // Token: 0x060006E4 RID: 1764
 // RVA: 0x000382C8 File Offset: 0x000364C8
 private void ReadElement(JsonReader reader, IXmlDocument document, IXmlNode currentNode, string propertyName, XmlNamespaceManager manager)
 {
     if (string.IsNullOrEmpty(propertyName))
     {
         throw new JsonSerializationException("XmlNodeConverter cannot convert JSON with an empty property name to XML.");
     }
     Dictionary<string, string> dictionary = this.ReadAttributeElements(reader, manager);
     string prefix = MiscellaneousUtils.GetPrefix(propertyName);
     if (StringUtils.StartsWith(propertyName, '@'))
     {
         string text = propertyName.Substring(1);
         string value = reader.Value.ToString();
         string prefix2 = MiscellaneousUtils.GetPrefix(text);
         IXmlNode attributeNode = (!string.IsNullOrEmpty(prefix2)) ? document.CreateAttribute(text, manager.LookupNamespace(prefix2), value) : document.CreateAttribute(text, value);
         ((IXmlElement)currentNode).SetAttributeNode(attributeNode);
         return;
     }
     IXmlElement xmlElement = this.CreateElement(propertyName, document, prefix, manager);
     currentNode.AppendChild(xmlElement);
     foreach (KeyValuePair<string, string> current in dictionary)
     {
         string prefix3 = MiscellaneousUtils.GetPrefix(current.Key);
         IXmlNode attributeNode2 = (!string.IsNullOrEmpty(prefix3)) ? document.CreateAttribute(current.Key, manager.LookupNamespace(prefix3), current.Value) : document.CreateAttribute(current.Key, current.Value);
         xmlElement.SetAttributeNode(attributeNode2);
     }
     if (reader.TokenType != JsonToken.String && reader.TokenType != JsonToken.Integer && reader.TokenType != JsonToken.Float && reader.TokenType != JsonToken.Boolean)
     {
         if (reader.TokenType != JsonToken.Date)
         {
             if (reader.TokenType == JsonToken.Null)
             {
                 return;
             }
             if (reader.TokenType != JsonToken.EndObject)
             {
                 manager.PushScope();
                 this.DeserializeNode(reader, document, manager, xmlElement);
                 manager.PopScope();
             }
             manager.RemoveNamespace(string.Empty, manager.DefaultNamespace);
             return;
         }
     }
     xmlElement.AppendChild(document.CreateTextNode(this.ConvertTokenToXmlValue(reader)));
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:47,代码来源:XmlNodeConverter.cs


示例19: ReadElement

        private void ReadElement(JsonReader reader, IXmlDocument document, IXmlNode currentNode, string propertyName, XmlNamespaceManager manager)
        {
            Dictionary<string, string> attributeNameValues = ReadAttributeElements(reader, manager);

              string elementPrefix = MiscellaneousUtils.GetPrefix(propertyName);

              IXmlElement element = CreateElement(propertyName, document, elementPrefix, manager);

              currentNode.AppendChild(element);

              // add attributes to newly created element
              foreach (KeyValuePair<string, string> nameValue in attributeNameValues)
              {
            string attributePrefix = MiscellaneousUtils.GetPrefix(nameValue.Key);

            IXmlNode attribute = (!string.IsNullOrEmpty(attributePrefix))
                               ? document.CreateAttribute(nameValue.Key, manager.LookupNamespace(attributePrefix), nameValue.Value)
                               : document.CreateAttribute(nameValue.Key, nameValue.Value);

            element.SetAttributeNode(attribute);
              }

              if (reader.TokenType == JsonToken.String)
              {
            element.AppendChild(document.CreateTextNode(reader.Value.ToString()));
              }
              else if (reader.TokenType == JsonToken.Integer)
              {
            element.AppendChild(document.CreateTextNode(XmlConvert.ToString((long)reader.Value)));
              }
              else if (reader.TokenType == JsonToken.Float)
              {
            element.AppendChild(document.CreateTextNode(XmlConvert.ToString((double)reader.Value)));
              }
              else if (reader.TokenType == JsonToken.Boolean)
              {
            element.AppendChild(document.CreateTextNode(XmlConvert.ToString((bool)reader.Value)));
              }
              else if (reader.TokenType == JsonToken.Date)
              {
            DateTime d = (DateTime)reader.Value;
            element.AppendChild(document.CreateTextNode(XmlConvert.ToString(d, DateTimeUtils.ToSerializationMode(d.Kind))));
              }
              else if (reader.TokenType == JsonToken.Null)
              {
            // empty element. do nothing
              }
              else
              {
            // finished element will have no children to deserialize
            if (reader.TokenType != JsonToken.EndObject)
            {
              manager.PushScope();

              DeserializeNode(reader, document, manager, element);

              manager.PopScope();
            }
              }
        }
开发者ID:WuziyiaoKingIris20140501,项目名称:KFC,代码行数:60,代码来源:XmlNodeConverter.cs


示例20: LoadFromXml

 public List<FileNotFoundException> LoadFromXml(IXmlDocument document) {
    throw new Exception("The method or operation is not implemented.");
 }
开发者ID:ManfredLange,项目名称:csUnit,代码行数:3,代码来源:FilterControlTests.cs



注:本文中的IXmlDocument类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IXmlLineInfo类代码示例发布时间:2022-05-24
下一篇:
C# IXmlDictionary类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap