本文整理汇总了C#中System.Xml.XmlNode.AppendChildForLoad方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.AppendChildForLoad方法的具体用法?C# XmlNode.AppendChildForLoad怎么用?C# XmlNode.AppendChildForLoad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNode
的用法示例。
在下文中一共展示了XmlNode.AppendChildForLoad方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParsePartialContent
internal XmlNamespaceManager ParsePartialContent(XmlNode parentNode, string innerxmltext, XmlNodeType nt)
{
//the function shouldn't be used to set innerxml for XmlDocument node
Debug.Assert(parentNode.NodeType != XmlNodeType.Document);
_doc = parentNode.OwnerDocument;
Debug.Assert(_doc != null);
XmlParserContext pc = GetContext(parentNode);
_reader = CreateInnerXmlReader(innerxmltext, nt, pc, _doc);
try
{
_preserveWhitespace = true;
bool bOrigLoading = _doc.IsLoading;
_doc.IsLoading = true;
if (nt == XmlNodeType.Entity)
{
XmlNode node = null;
while (_reader.Read() && (node = LoadNodeDirect()) != null)
{
parentNode.AppendChildForLoad(node, _doc);
}
}
else
{
XmlNode node = null;
while (_reader.Read() && (node = LoadNode(true)) != null)
{
parentNode.AppendChildForLoad(node, _doc);
}
}
_doc.IsLoading = bOrigLoading;
}
finally
{
_reader.Dispose();
}
return pc.NamespaceManager;
}
示例2: LoadAttributeValue
private void LoadAttributeValue(XmlNode parent, bool direct)
{
XmlReader r = _reader;
while (r.ReadAttributeValue())
{
XmlNode node;
switch (r.NodeType)
{
case XmlNodeType.Text:
node = direct ? new XmlText(r.Value, _doc) : _doc.CreateTextNode(r.Value);
break;
case XmlNodeType.EndEntity:
return;
case XmlNodeType.EntityReference:
node = direct ? new XmlEntityReference(_reader.LocalName, _doc) : _doc.CreateEntityReference(_reader.LocalName);
if (r.CanResolveEntity)
{
r.ResolveEntity();
LoadAttributeValue(node, direct);
// Code internally relies on the fact that an EntRef nodes has at least one child (even an empty text node). Ensure that this holds true,
// if the reader does not present any children for the ent-ref
if (node.FirstChild == null)
{
node.AppendChildForLoad(direct ? new XmlText(string.Empty) : _doc.CreateTextNode(string.Empty), _doc);
}
}
break;
default:
throw UnexpectedNodeType(r.NodeType);
}
Debug.Assert(node != null);
parent.AppendChildForLoad(node, _doc);
}
return;
}
示例3: ParsePartialContent
internal XmlNamespaceManager ParsePartialContent(XmlNode parentNode, string innerxmltext, XmlNodeType nt)
{
this.doc = parentNode.OwnerDocument;
XmlParserContext context = this.GetContext(parentNode);
this.reader = this.CreateInnerXmlReader(innerxmltext, nt, context, this.doc);
try
{
this.preserveWhitespace = true;
bool isLoading = this.doc.IsLoading;
this.doc.IsLoading = true;
if (nt == XmlNodeType.Entity)
{
XmlNode newChild = null;
while (this.reader.Read() && ((newChild = this.LoadNodeDirect()) != null))
{
parentNode.AppendChildForLoad(newChild, this.doc);
}
}
else
{
XmlNode node2 = null;
while (this.reader.Read() && ((node2 = this.LoadNode(true)) != null))
{
parentNode.AppendChildForLoad(node2, this.doc);
}
}
this.doc.IsLoading = isLoading;
}
finally
{
this.reader.Close();
}
return context.NamespaceManager;
}
示例4: LoadChildren
// The way it is getting called guarantees that the reader is pointing at an element node or entity node, or the reader is
// at Initial status. In this cases, LoadChildren will stop when nodes in the lower level are all consumed.
private void LoadChildren( XmlNode parent ) {
Debug.Assert( parent != null );
XmlNode node = null;
while ( reader.Read() && (node = LoadCurrentNode()) != null ) {
parent.AppendChildForLoad( node, doc );
}
}
示例5: LoadAttributeValue
private void LoadAttributeValue(XmlNode parent, bool direct)
{
XmlReader reader = this.reader;
while (reader.ReadAttributeValue())
{
XmlNode node;
switch (reader.NodeType)
{
case XmlNodeType.Text:
node = direct ? new XmlText(reader.Value, this.doc) : this.doc.CreateTextNode(reader.Value);
break;
case XmlNodeType.EntityReference:
node = direct ? new XmlEntityReference(this.reader.LocalName, this.doc) : this.doc.CreateEntityReference(this.reader.LocalName);
if (reader.CanResolveEntity)
{
reader.ResolveEntity();
this.LoadAttributeValue(node, direct);
if (node.FirstChild == null)
{
node.AppendChildForLoad(direct ? new XmlText(string.Empty) : this.doc.CreateTextNode(string.Empty), this.doc);
}
}
break;
case XmlNodeType.EndEntity:
return;
default:
throw UnexpectedNodeType(reader.NodeType);
}
parent.AppendChildForLoad(node, this.doc);
}
}