本文整理汇总了C#中XmlTextWriter.WriteNode方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextWriter.WriteNode方法的具体用法?C# XmlTextWriter.WriteNode怎么用?C# XmlTextWriter.WriteNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlTextWriter
的用法示例。
在下文中一共展示了XmlTextWriter.WriteNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadOuterXml
public virtual string ReadOuterXml ()
{
if (ReadState != ReadState.Interactive || NodeType == XmlNodeType.EndElement)
return String.Empty;
switch (NodeType) {
case XmlNodeType.Element:
case XmlNodeType.Attribute:
StringWriter sw = new StringWriter ();
XmlTextWriter xtw = new XmlTextWriter (sw);
xtw.WriteNode (this, false);
return sw.ToString ();
default:
Skip ();
return String.Empty;
}
}
示例2: ReadInnerXml
public virtual string ReadInnerXml ()
{
if (ReadState != ReadState.Interactive || NodeType == XmlNodeType.EndElement)
return String.Empty;
if (IsEmptyElement) {
Read ();
return String.Empty;
}
StringWriter sw = new StringWriter ();
XmlTextWriter xtw = new XmlTextWriter (sw);
if (NodeType == XmlNodeType.Element) {
int startDepth = Depth;
Read ();
while (startDepth < Depth) {
if (ReadState != ReadState.Interactive)
throw XmlError ("Unexpected end of the XML reader.");
xtw.WriteNode (this, false);
}
// reader is now end element, then proceed once more.
Read ();
}
else
xtw.WriteNode (this, false);
return sw.ToString ();
}