本文整理汇总了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;
}
示例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;
}
}
}
}
示例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));
}
}
示例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();
}
}
}
示例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;
}
示例6: ReadXml
public void ReadXml(XmlReader reader)
{
//goto inner hidden
reader.Read();
Text = reader.ReadInnerXml();
reader.Read();
}
示例7: ReadXml
public override void ReadXml(XmlReader reader)
{
Name = reader.GetAttribute("name");
Description = reader.ReadInnerXml().Trim();
if (Description.Contains("this method interface declaration"))
{
}
}
示例8: FromXmlReader
public string FromXmlReader (XmlReader reader)
{
if (!reader.ReadToDescendant ("head"))
return null;
if (!reader.ReadToNextSibling ("body"))
return null;
return reader.ReadInnerXml ();
}
示例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;
}
示例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;
}
示例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);
}
示例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));
}
}
示例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("<"))
{
#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);
}
示例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();
}
示例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);
}
}
}