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


C# XmlReader.ReadInnerXml方法代码示例

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


在下文中一共展示了XmlReader.ReadInnerXml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DecodeXmlTextReaderValue

        internal static bool DecodeXmlTextReaderValue(object instance, PropertyInfo propertyInfo, XmlReader xmlTextReader)
        {
            try
            {
                // find related property by name if not provided as parameter
                if (propertyInfo == null)
                    propertyInfo = instance.GetType().GetProperty(xmlTextReader.Name, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);

                if (propertyInfo == null)
                    return false;
                // unescaped characters <>&
                if (propertyInfo.PropertyType.Equals(typeof(string)))
                    propertyInfo.SetValue(instance, Decode(xmlTextReader.ReadInnerXml().Trim()), null);
                else if (propertyInfo.PropertyType.Equals(typeof(DateTime)))
                    propertyInfo.SetValue(instance, ParseRfc822DateTime(xmlTextReader.ReadInnerXml().Trim()), null);
                else
                    propertyInfo.SetValue(instance, TypeDescriptor.GetConverter(propertyInfo.PropertyType).ConvertFromString(xmlTextReader.ReadInnerXml().Trim()), null);
            }
            catch (Exception e)
            {
                Debug.WriteLine(propertyInfo.Name + ", " + propertyInfo.PropertyType.Name + " / " + instance.ToString() + " " + e.Message);
                return false;
            }
            return true;
        }
开发者ID:miracle091,项目名称:transmission-remote-dotnet,代码行数:25,代码来源:XmlSerializationUtil.cs

示例2: PopulateFromXml

 public override void PopulateFromXml(XmlReader reader)
 {
     if (reader.LocalName != "item" || reader.GetAttribute("type") != "category")
         return;  // If we weren't on the right kind of node, do nothing
     GuidStr = reader.GetAttribute("guid");
     while (reader.Read())
     {
         switch (reader.NodeType)
         {
         case XmlNodeType.Element:
             {
                 switch (reader.LocalName)
                 {
                 case "item":
                     if (reader.GetAttribute("type") == "category")
                     {
                         var child = new CanonicalPartOfSpeechItem();
                         child.PopulateFromXml(reader);
                         AppendChild(child);
                     }
                     break;
                 case "abbrev":
                     AddAbbrev(reader.GetAttribute("ws"), reader.ReadInnerXml());
                     break;
                 case "term":
                     AddName(reader.GetAttribute("ws"), reader.ReadInnerXml());
                     break;
                 case "def":
                     AddDescription(reader.GetAttribute("ws"), reader.ReadInnerXml());
                     break;
                 case "citation":
                     Dictionary<string, List<string>> citationsDict = GetExtraDataWsDict<string>("citations");
                     string ws = reader.GetAttribute("ws");
                     List<string> citations = GetListFromDict<string>(citationsDict, ws);
                     citations.Add(reader.ReadInnerXml());
                     // No need to set anything in ExtraData, as GetListFromDict did it for us.
                     break;
                 }
                 break;
             }
         case XmlNodeType.EndElement:
             {
                 if (reader.LocalName == "item")
                 {
                     Key = AbbrevByWs(KeyWs);
                     reader.Read(); // Skip past the closing element before returning
                     return;
                 }
                 break;
             }
         }
     }
 }
开发者ID:ermshiperete,项目名称:LfMerge,代码行数:53,代码来源:CanonicalPartOfSpeechItem.cs

示例3: AttributeAssignmentElementReadWrite

        /// <summary>
        /// Creates an instance of the ReadWriteAttributeAssignment using the provided XmlReader.
        /// </summary>
        /// <param name="reader">The XmlReader positioned at the AttributeAssignament node.</param>
        /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
        public AttributeAssignmentElementReadWrite(XmlReader reader, XacmlVersion schemaVersion)
            : base(XacmlSchema.Policy, schemaVersion)
        {
            if (reader == null) throw new ArgumentNullException("reader");
            if (reader.LocalName == Consts.Schema1.ObligationElement.AttributeAssignment &&
                ValidateSchema(reader, schemaVersion))
            {
                if (reader.HasAttributes)
                {
                    // Load all the attributes
                    while (reader.MoveToNextAttribute())
                    {
                        if (reader.LocalName == Consts.Schema1.AttributeValueElement.DataType)
                        {
                            _dataType = reader.GetAttribute(Consts.Schema1.AttributeValueElement.DataType);
                        }
                        else if (reader.LocalName == Consts.Schema1.AttributeAssignmentElement.AttributeId)
                        {
                            _attributeId = reader.GetAttribute(Consts.Schema1.AttributeAssignmentElement.AttributeId);
                        }
                    }
                    reader.MoveToElement();
                }

                // Load the node contents
                _contents = reader.ReadInnerXml();
            }
            else
            {
                throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
            }
        }
开发者ID:mingkongbin,项目名称:anycmd,代码行数:37,代码来源:AttributeAssignmentElementReadWrite.cs

示例4: ReadXml

		public void ReadXml(XmlReader reader)
		{
			m_name = reader.Name;
			while (reader.Read())
			{
				reader.SkipEmptyNodes();

				if (reader.NodeType == XmlNodeType.EndElement)
				{
					// the end
					break;
				}
				else if (reader.NodeType == XmlNodeType.Element)
				{
					reader.Read();	// go into ValueNode
					reader.SkipEmptyNodes();
				}

				if (reader.NodeType != XmlNodeType.Text)
				{
					throw new Exception("Required NodeType: Text - Found: " + reader.NodeType);
				}

				var value = reader.ReadContentAsString();
				Pairs.Add(new KeyValuePair<string, string>(reader.Name, value));

				if (reader.NodeType == XmlNodeType.EndElement)
				{
					// the end
					reader.ReadInnerXml();
				}
			}
		}
开发者ID:remixod,项目名称:netServer,代码行数:33,代码来源:SerializablePairCollection.cs

示例5: Deserialize

        public static object Deserialize(Type type, XmlReader reader, bool readInnerXml)
        {
            if (null == type) throw new ArgumentNullException("type");
            if (null == reader) throw new ArgumentNullException("reader");
            if (reader.NodeType != XmlNodeType.Element) throw new ArgumentException("reader is not positioned on an element");

            object value = null;
            StringBuilder serializationBuilder = new StringBuilder();
            serializationBuilder.Append("<?xml version=\"1.0\"?>");
            if (readInnerXml)
            {
                serializationBuilder.AppendLine(reader.ReadInnerXml());
            }
            else
            {
                serializationBuilder.AppendLine(reader.ReadOuterXml());
            }
            string serialization = serializationBuilder.ToString();
            using (StringReader stringReader = new StringReader(serialization))
            {
                XmlSerializer serializer = new XmlSerializer(type);
                value = serializer.Deserialize(stringReader);
            }
            return value;
        }
开发者ID:t1b1c,项目名称:lwas,代码行数:25,代码来源:SerializationServices.cs

示例6: ReadXml

		public void ReadXml(XmlReader reader)
		{
			//goto inner hidden
			reader.Read();
		    Text = reader.ReadInnerXml();
			reader.Read();
		}
开发者ID:Korshunoved,项目名称:Win10reader,代码行数:7,代码来源:Hidden.cs

示例7: ReadXml

 public override void ReadXml(XmlReader reader)
 {
     Name = reader.GetAttribute("name");
     Description = reader.ReadInnerXml().Trim();
     if (Description.Contains("this method interface declaration"))
     {
     }
 }
开发者ID:reinforced,项目名称:Reinforced.Typings,代码行数:8,代码来源:Model.cs

示例8: FromXmlReader

		public string FromXmlReader (XmlReader reader)
		{
			if (!reader.ReadToDescendant ("head"))
				return null;
			if (!reader.ReadToNextSibling ("body"))
				return null;

			return reader.ReadInnerXml ();
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:9,代码来源:MonoBook2Html.cs

示例9: ReadXml

            /// <summary>
            /// 读取Xml
            /// </summary>
            /// <param name="reader"></param>
            public void ReadXml(XmlReader reader)
            {
                String prefix = reader.Prefix;

                String xml = reader.ReadInnerXml();
                if (xml.StartsWith("<Fault") || xml.StartsWith("<" + prefix + ":Fault"))
                    Fault = xml;
                else
                    Xml = xml;
            }
开发者ID:windygu,项目名称:asxinyunet,代码行数:14,代码来源:Envelope.cs

示例10: ReadRSAKeyValue

        private static SecurityKeyIdentifierClause ReadRSAKeyValue(XmlReader reader)
        {
            string rsaXmlElement = reader.ReadInnerXml();

            var rsa = new RSACryptoServiceProvider(); // Do not dispose! Used later when creating key
            rsa.FromXmlString(rsaXmlElement);
            RsaKeyIdentifierClause clause = new RsaKeyIdentifierClause(rsa);

            return clause;
        }
开发者ID:CDHDeveloper,项目名称:authservices,代码行数:10,代码来源:KeyInfoSerializer.cs

示例11:

 void IXmlSerializable.ReadXml(XmlReader reader)
 {
     string s = reader.ReadInnerXml();
     string startTag = "<![CDATA[";
     string endTag = "]]>";
     char[] trims = new char[] { '\r', '\n', '\t', ' ' };
     s = s.Trim(trims);
     if (s.StartsWith(startTag) && s.EndsWith(endTag))
     {
         s = s.Substring(startTag.Length, s.LastIndexOf(endTag) - startTag.Length);
     }
     this._innerSourceXml = s;
     this._innerXml = s.Trim(trims);
 }
开发者ID:Microshaoft,项目名称:Microshaoft.Common.Utilities.Net.4x,代码行数:14,代码来源:XmlCDATA.cs

示例12: AttributeValueElementReadWrite

 /// <summary>
 /// Creates an instance of the AttributeValue using the XmlReader provided.
 /// </summary>
 /// <param name="reader">The XmlReader positioned at the AttributeValue node.</param>
 /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
 public AttributeValueElementReadWrite(XmlReader reader, XacmlVersion schemaVersion)
     : base(XacmlSchema.Context, schemaVersion)
 {
     if (reader == null) throw new ArgumentNullException("reader");
     if (reader.LocalName == Consts.ContextSchema.AttributeElement.AttributeValue &&
         ValidateSchema(reader, schemaVersion))
     {
         // Load the node contents
         _contents = reader.ReadInnerXml();
     }
     else
     {
         throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
     }
 }
开发者ID:mingkongbin,项目名称:anycmd,代码行数:20,代码来源:AttributeValueElementReadWrite.cs

示例13: XmlSerializationContextInfo

        /// <summary>
        /// Initializes a new instance of the <see cref="XmlSerializationContextInfo" /> class.
        /// </summary>
        /// <param name="xmlReader">The XML reader.</param>
        /// <param name="model">The model.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="xmlReader" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="model" /> is <c>null</c>.</exception>
        public XmlSerializationContextInfo(XmlReader xmlReader, ModelBase model)
        {
            Argument.IsNotNull("xmlReader", xmlReader);
            Argument.IsNotNull("model", model);

            var modelType = model.GetType();
            var elementStart = string.Format("<{0}", modelType.Name);

            if (xmlReader.HasAttributes)
            {
                for (int i = 0; i < xmlReader.AttributeCount; i++)
                {
                    xmlReader.MoveToAttribute(i);

                    var attributeName = xmlReader.LocalName;
                    var attributeValue = xmlReader.Value;

                    elementStart += string.Format(" {0}=\"{1}\"", attributeName, attributeValue);
                }

                xmlReader.MoveToElement();
            }

            elementStart += ">";

            xmlReader.MoveToContent();

            var xmlContent = xmlReader.ReadInnerXml();
            if (xmlContent.StartsWith("&lt;"))
            {
#if SL5
                xmlContent = System.Windows.Browser.HttpUtility.HtmlDecode(xmlContent);
#else
                xmlContent = System.Net.WebUtility.HtmlDecode(xmlContent);
#endif
            }

            var elementEnd = string.Format("</{0}>", modelType.Name);

            var finalXmlContent = string.Format("{0}{1}{2}", elementStart, xmlContent, elementEnd);
            Initialize(finalXmlContent, model);
        }
开发者ID:matthijskoopman,项目名称:Catel,代码行数:49,代码来源:XmlSerializationContextInfo.cs

示例14: ReadXml

        /// <summary>
        /// Generates a <see cref="SerializableError"/> object from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="XmlReader"/> stream from which the object is deserialized.</param>
        public void ReadXml(XmlReader reader)
        {
            if (reader.IsEmptyElement)
            {
                reader.Read();
                return;
            }

            reader.ReadStartElement();
            while (reader.NodeType != XmlNodeType.EndElement)
            {
                var key = XmlConvert.DecodeName(reader.LocalName);
                var value = reader.ReadInnerXml();

                SerializableError.Add(key, value);
                reader.MoveToContent();
            }

            reader.ReadEndElement();
        }
开发者ID:ymd1223,项目名称:Mvc,代码行数:24,代码来源:SerializableErrorWrapper.cs

示例15: RssCloud

        /// <summary>Initializes a new instance of RssCloud</summary>
        public RssCloud(XmlReader xmlTextReader)
        {
            if (!xmlTextReader.HasAttributes)
                return;

            PropertyInfo propertyInfo = null;

            while (xmlTextReader.MoveToNextAttribute())
            {
                // find related property by name
                propertyInfo = GetType().GetProperty(xmlTextReader.Name, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
                if (propertyInfo != null)
                {
                    // Protocol enum needs some conversion before the typeconverter can set the values that contains - char
                    if (propertyInfo.Name == "Protocol")
                        propertyInfo.SetValue(this, TypeDescriptor.GetConverter(propertyInfo.PropertyType).ConvertFromString(xmlTextReader.ReadInnerXml().Trim().Replace("-", "")), null);
                    else
                        XmlSerializationUtil.DecodeXmlTextReaderValue(this, xmlTextReader);
                }
            }
        }
开发者ID:miracle091,项目名称:transmission-remote-dotnet,代码行数:22,代码来源:rsscloud.cs


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