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


C# IXmlDocument.CreateTextNode方法代码示例

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


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

示例3: DeserializeValue

    private void DeserializeValue(JsonReader reader, IXmlDocument document, XmlNamespaceManager manager, string propertyName, IXmlNode currentNode)
    {
      switch (propertyName)
      {
        case TextName:
          currentNode.AppendChild(document.CreateTextNode(reader.Value.ToString()));
          break;
        case CDataName:
          currentNode.AppendChild(document.CreateCDataSection(reader.Value.ToString()));
          break;
        case WhitespaceName:
          currentNode.AppendChild(document.CreateWhitespace(reader.Value.ToString()));
          break;
        case SignificantWhitespaceName:
          currentNode.AppendChild(document.CreateSignificantWhitespace(reader.Value.ToString()));
          break;
        default:
          // processing instructions and the xml declaration start with ?
          if (!string.IsNullOrEmpty(propertyName) && propertyName[0] == '?')
          {
            CreateInstruction(reader, document, currentNode, propertyName);
          }
          else
          {
            if (reader.TokenType == JsonToken.StartArray)
            {
              // handle nested arrays
              ReadArrayElements(reader, document, propertyName, currentNode, manager);
              return;
            }

            // have to wait until attributes have been parsed before creating element
            // attributes may contain namespace info used by the element
            ReadElement(reader, document, currentNode, propertyName, manager);
          }
          break;
      }
    }
开发者ID:284247028,项目名称:MvvmCross,代码行数:38,代码来源:XmlNodeConverter.cs

示例4: CreateElement

        private void CreateElement(JsonReader reader, IXmlDocument document, IXmlNode currentNode, string elementName, XmlNamespaceManager manager, string elementPrefix, Dictionary<string, string> attributeNameValues)
        {
            IXmlElement element = CreateElement(elementName, 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) ?? string.Empty, 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();
                }

                manager.RemoveNamespace(string.Empty, manager.DefaultNamespace);
            }
        }
开发者ID:b-bot-110,项目名称:Newtonsoft.Json,代码行数:43,代码来源:XmlNodeConverter.cs

示例5: 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

示例6: 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

示例7: DeserializeValue

 // Token: 0x060006E3 RID: 1763
 // RVA: 0x000381B4 File Offset: 0x000363B4
 private void DeserializeValue(JsonReader reader, IXmlDocument document, XmlNamespaceManager manager, string propertyName, IXmlNode currentNode)
 {
     if (propertyName != null)
     {
         if (propertyName == "#text")
         {
             currentNode.AppendChild(document.CreateTextNode(reader.Value.ToString()));
             return;
         }
         if (propertyName == "#cdata-section")
         {
             currentNode.AppendChild(document.CreateCDataSection(reader.Value.ToString()));
             return;
         }
         if (propertyName == "#whitespace")
         {
             currentNode.AppendChild(document.CreateWhitespace(reader.Value.ToString()));
             return;
         }
         if (propertyName == "#significant-whitespace")
         {
             currentNode.AppendChild(document.CreateSignificantWhitespace(reader.Value.ToString()));
             return;
         }
     }
     if (!string.IsNullOrEmpty(propertyName) && propertyName[0] == '?')
     {
         this.CreateInstruction(reader, document, currentNode, propertyName);
         return;
     }
     if (string.Equals(propertyName, "!DOCTYPE", StringComparison.OrdinalIgnoreCase))
     {
         this.CreateDocumentType(reader, document, currentNode);
         return;
     }
     if (reader.TokenType == JsonToken.StartArray)
     {
         this.ReadArrayElements(reader, document, propertyName, currentNode, manager);
         return;
     }
     this.ReadElement(reader, document, currentNode, propertyName, manager);
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:44,代码来源:XmlNodeConverter.cs

示例8: 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> dictionary = this.ReadAttributeElements(reader, manager);
   string prefix1 = MiscellaneousUtils.GetPrefix(propertyName);
   if (propertyName.StartsWith("@"))
   {
     string str1 = propertyName.Substring(1);
     string str2 = reader.Value.ToString();
     string prefix2 = MiscellaneousUtils.GetPrefix(str1);
     IXmlNode attribute = !string.IsNullOrEmpty(prefix2) ? document.CreateAttribute(str1, manager.LookupNamespace(prefix2), str2) : document.CreateAttribute(str1, str2);
     ((IXmlElement) currentNode).SetAttributeNode(attribute);
   }
   else
   {
     IXmlElement element = this.CreateElement(propertyName, document, prefix1, manager);
     currentNode.AppendChild((IXmlNode) element);
     foreach (KeyValuePair<string, string> keyValuePair in dictionary)
     {
       string prefix2 = MiscellaneousUtils.GetPrefix(keyValuePair.Key);
       IXmlNode attribute = !string.IsNullOrEmpty(prefix2) ? document.CreateAttribute(keyValuePair.Key, manager.LookupNamespace(prefix2), keyValuePair.Value) : document.CreateAttribute(keyValuePair.Key, keyValuePair.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(this.ConvertTokenToXmlValue(reader)));
     }
     else
     {
       if (reader.TokenType == JsonToken.Null || reader.TokenType == JsonToken.EndObject)
         return;
       manager.PushScope();
       this.DeserializeNode(reader, document, manager, (IXmlNode) element);
       manager.PopScope();
     }
   }
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:38,代码来源:XmlNodeConverter.cs

示例9: DeserializeValue

 private void DeserializeValue(JsonReader reader, IXmlDocument document, XmlNamespaceManager manager, string propertyName, IXmlNode currentNode)
 {
   switch (propertyName)
   {
     case "#text":
       currentNode.AppendChild(document.CreateTextNode(reader.Value.ToString()));
       break;
     case "#cdata-section":
       currentNode.AppendChild(document.CreateCDataSection(reader.Value.ToString()));
       break;
     case "#whitespace":
       currentNode.AppendChild(document.CreateWhitespace(reader.Value.ToString()));
       break;
     case "#significant-whitespace":
       currentNode.AppendChild(document.CreateSignificantWhitespace(reader.Value.ToString()));
       break;
     default:
       if (!string.IsNullOrEmpty(propertyName) && (int) propertyName[0] == 63)
       {
         this.CreateInstruction(reader, document, currentNode, propertyName);
         break;
       }
       else if (reader.TokenType == JsonToken.StartArray)
       {
         this.ReadArrayElements(reader, document, propertyName, currentNode, manager);
         break;
       }
       else
       {
         this.ReadElement(reader, document, currentNode, propertyName, manager);
         break;
       }
   }
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:34,代码来源:XmlNodeConverter.cs

示例10: 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.");

            var attributeNameValues = ReadAttributeElements(reader, manager);
            var 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
            {
                var element = CreateElement(propertyName, document, elementPrefix, manager);

                currentNode.AppendChild(element);

                // add attributes to newly created element
                foreach (var nameValue in attributeNameValues)
                {
                    var attributePrefix = MiscellaneousUtils.GetPrefix(nameValue.Key);
                    var attribute = (!string.IsNullOrEmpty(attributePrefix)) ? document.CreateAttribute(nameValue.Key, manager.LookupNamespace(attributePrefix) ?? string.Empty, nameValue.Value) : document.CreateAttribute(nameValue.Key, nameValue.Value);
                    element.SetAttributeNode(attribute);
                }

                switch (reader.TokenType)
                {
                    case JsonToken.Date:
                    case JsonToken.Boolean:
                    case JsonToken.Float:
                    case JsonToken.Integer:
                    case JsonToken.String:
                        element.AppendChild(document.CreateTextNode(ConvertTokenToXmlValue(reader)));
                        break;
                    case JsonToken.Null:
                        break;
                    default:
                        if (reader.TokenType != JsonToken.EndObject)
                        {
                            manager.PushScope();
                            DeserializeNode(reader, document, manager, element);
                            manager.PopScope();
                        }
                        manager.RemoveNamespace(string.Empty, manager.DefaultNamespace);
                        break;
                }
            }
        }
开发者ID:sat1582,项目名称:CODEFramework,代码行数:52,代码来源:XmlNodeConverter.cs


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