当前位置: 首页>>代码示例>>C#>>正文


C# IXmlDocument类代码示例

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


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


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