12 [DebuggerDisplay(
"{debuggerDisplayProxy}")]
19 public abstract string Name 35 public virtual string Value 68 if (xmlLinkedNode !=
null)
73 if (xmlLinkedNode2 ==
this)
77 xmlLinkedNode2 = xmlLinkedNode2.next;
79 while (xmlLinkedNode2 !=
null && xmlLinkedNode2 != xmlLinkedNode);
123 internal virtual bool IsContainer =>
false;
149 public virtual string Prefix 175 return HasReadOnlyParent(
this);
186 if (firstChild ==
null)
198 return firstChild.
Value;
202 AppendChildText(stringBuilder);
210 firstChild.
Value = value;
226 XmlDOMTextWriter xmlDOMTextWriter =
new XmlDOMTextWriter(stringWriter);
233 xmlDOMTextWriter.Close();
249 XmlDOMTextWriter xmlDOMTextWriter =
new XmlDOMTextWriter(stringWriter);
256 xmlDOMTextWriter.Close();
278 switch (xmlNode.NodeType)
285 return xmlNode.BaseURI;
307 public virtual XmlElement
this[
string name]
313 if (xmlNode.NodeType ==
XmlNodeType.Element && xmlNode.Name == name)
326 public virtual XmlElement this[
string localname,
string ns]
332 if (xmlNode.NodeType ==
XmlNodeType.Element && xmlNode.LocalName == localname && xmlNode.NamespaceURI == ns)
350 if (xmlElement !=
null && xmlElement.
HasAttribute(
"xml:space"))
359 return XmlSpace.Preserve;
364 while (xmlNode !=
null);
365 return XmlSpace.None;
369 internal virtual string XmlLang
373 XmlNode xmlNode =
this;
374 XmlElement xmlElement =
null;
377 xmlElement = (xmlNode as XmlElement);
378 if (xmlElement !=
null && xmlElement.HasAttribute(
"xml:lang"))
382 xmlNode = xmlNode.ParentNode;
384 while (xmlNode !=
null);
391 internal virtual string XPLocalName =>
string.Empty;
393 internal virtual bool IsText =>
false;
399 private object debuggerDisplayProxy =>
new DebuggerDisplayXmlNodeProxy(
this);
419 if (xmlDocument !=
null)
444 if (xPathNavigator ==
null)
450 return new XPathNodeList(xPathNavigator.
Select(xPathExpression))[0];
460 if (xPathNavigator ==
null)
464 return new XPathNodeList(xPathNavigator.
Select(xpath));
475 if (xPathNavigator ==
null)
481 return new XPathNodeList(xPathNavigator.
Select(xPathExpression));
484 internal bool AncestorNode(
XmlNode node)
487 while (xmlNode !=
null && xmlNode !=
this)
498 internal bool IsConnected()
501 while (xmlNode !=
null && xmlNode.NodeType !=
XmlNodeType.Document)
505 return xmlNode !=
null;
516 if (
this == newChild || AncestorNode(newChild))
520 if (refChild ==
null)
532 if (newChild == refChild)
538 if (ownerDocument !=
null && ownerDocument != ownerDocument2 && ownerDocument !=
this)
542 if (!CanInsertBefore(newChild, refChild))
568 string value = newChild.
Value;
570 if (eventArgs !=
null)
572 BeforeEvent(eventArgs);
576 xmlLinkedNode.next = xmlLinkedNode2;
577 LastNode.next = xmlLinkedNode;
578 xmlLinkedNode.SetParent(
this);
579 if (xmlLinkedNode.IsText && xmlLinkedNode2.IsText)
581 NestTextNodes(xmlLinkedNode, xmlLinkedNode2);
587 xmlLinkedNode.next = xmlLinkedNode2;
588 xmlLinkedNode3.next = xmlLinkedNode;
589 xmlLinkedNode.SetParent(
this);
590 if (xmlLinkedNode3.IsText)
592 if (xmlLinkedNode.IsText)
594 NestTextNodes(xmlLinkedNode3, xmlLinkedNode);
595 if (xmlLinkedNode2.IsText)
597 NestTextNodes(xmlLinkedNode, xmlLinkedNode2);
600 else if (xmlLinkedNode2.IsText)
602 UnnestTextNodes(xmlLinkedNode3, xmlLinkedNode2);
605 else if (xmlLinkedNode.IsText && xmlLinkedNode2.IsText)
607 NestTextNodes(xmlLinkedNode, xmlLinkedNode2);
610 if (eventArgs !=
null)
612 AfterEvent(eventArgs);
614 return xmlLinkedNode;
625 if (
this == newChild || AncestorNode(newChild))
629 if (refChild ==
null)
641 if (newChild == refChild)
647 if (ownerDocument !=
null && ownerDocument != ownerDocument2 && ownerDocument !=
this)
651 if (!CanInsertAfter(newChild, refChild))
664 for (
XmlNode xmlNode = firstChild; xmlNode !=
null; xmlNode = nextSibling)
679 string value = newChild.
Value;
681 if (eventArgs !=
null)
683 BeforeEvent(eventArgs);
685 if (xmlLinkedNode2 == LastNode)
687 xmlLinkedNode.next = xmlLinkedNode2.next;
688 xmlLinkedNode2.next = xmlLinkedNode;
689 LastNode = xmlLinkedNode;
690 xmlLinkedNode.SetParent(
this);
691 if (xmlLinkedNode2.IsText && xmlLinkedNode.IsText)
693 NestTextNodes(xmlLinkedNode2, xmlLinkedNode);
698 XmlLinkedNode xmlLinkedNode3 = xmlLinkedNode.next = xmlLinkedNode2.next;
699 xmlLinkedNode2.next = xmlLinkedNode;
700 xmlLinkedNode.SetParent(
this);
701 if (xmlLinkedNode2.IsText)
703 if (xmlLinkedNode.IsText)
705 NestTextNodes(xmlLinkedNode2, xmlLinkedNode);
706 if (xmlLinkedNode3.IsText)
708 NestTextNodes(xmlLinkedNode, xmlLinkedNode3);
711 else if (xmlLinkedNode3.IsText)
713 UnnestTextNodes(xmlLinkedNode2, xmlLinkedNode3);
716 else if (xmlLinkedNode.IsText && xmlLinkedNode3.IsText)
718 NestTextNodes(xmlLinkedNode, xmlLinkedNode3);
721 if (eventArgs !=
null)
723 AfterEvent(eventArgs);
725 return xmlLinkedNode;
757 string value = xmlLinkedNode.
Value;
759 if (eventArgs !=
null)
761 BeforeEvent(eventArgs);
766 if (xmlLinkedNode == lastNode)
769 xmlLinkedNode.next =
null;
770 xmlLinkedNode.SetParent(
null);
775 if (next.IsText && xmlLinkedNode.IsText)
777 UnnestTextNodes(xmlLinkedNode, next);
779 lastNode.next = next;
780 xmlLinkedNode.next =
null;
781 xmlLinkedNode.SetParent(
null);
784 else if (xmlLinkedNode == lastNode)
787 xmlLinkedNode2.next = xmlLinkedNode.next;
788 LastNode = xmlLinkedNode2;
789 xmlLinkedNode.next =
null;
790 xmlLinkedNode.SetParent(
null);
798 if (xmlLinkedNode3.IsText)
800 NestTextNodes(xmlLinkedNode3, next2);
802 else if (xmlLinkedNode.IsText)
804 UnnestTextNodes(xmlLinkedNode, next2);
807 xmlLinkedNode3.next = next2;
808 xmlLinkedNode.next =
null;
809 xmlLinkedNode.SetParent(
null);
811 if (eventArgs !=
null)
813 AfterEvent(eventArgs);
836 if (xmlDocument ==
null)
844 if (
this == newChild || AncestorNode(newChild))
853 if (ownerDocument !=
null && ownerDocument != xmlDocument && ownerDocument !=
this)
861 for (
XmlNode xmlNode = firstChild; xmlNode !=
null; xmlNode = nextSibling)
873 if (!CanInsertAfter(newChild,
LastChild))
877 string value = newChild.
Value;
879 if (eventArgs !=
null)
881 BeforeEvent(eventArgs);
885 if (lastNode ==
null)
887 xmlLinkedNode.next = xmlLinkedNode;
888 LastNode = xmlLinkedNode;
889 xmlLinkedNode.SetParent(
this);
893 xmlLinkedNode.next = lastNode.next;
894 lastNode.next = xmlLinkedNode;
895 LastNode = xmlLinkedNode;
896 xmlLinkedNode.SetParent(
this);
897 if (lastNode.IsText && xmlLinkedNode.IsText)
899 NestTextNodes(lastNode, xmlLinkedNode);
902 if (eventArgs !=
null)
904 AfterEvent(eventArgs);
906 return xmlLinkedNode;
912 if (insertEventArgsForLoad !=
null)
914 doc.BeforeEvent(insertEventArgsForLoad);
916 XmlLinkedNode lastNode = LastNode;
917 XmlLinkedNode xmlLinkedNode = (XmlLinkedNode)newChild;
918 if (lastNode ==
null)
920 xmlLinkedNode.next = xmlLinkedNode;
921 LastNode = xmlLinkedNode;
922 xmlLinkedNode.SetParentForLoad(
this);
926 xmlLinkedNode.next = lastNode.next;
927 lastNode.next = xmlLinkedNode;
928 LastNode = xmlLinkedNode;
929 if (lastNode.IsText && xmlLinkedNode.IsText)
931 NestTextNodes(lastNode, xmlLinkedNode);
935 xmlLinkedNode.SetParentForLoad(
this);
938 if (insertEventArgsForLoad !=
null)
940 doc.AfterEvent(insertEventArgsForLoad);
942 return xmlLinkedNode;
945 internal virtual bool IsValidChildType(
XmlNodeType type)
950 internal virtual bool CanInsertBefore(XmlNode newChild, XmlNode refChild)
955 internal virtual bool CanInsertAfter(XmlNode newChild, XmlNode refChild)
965 public abstract XmlNode
CloneNode(
bool deep);
967 internal virtual void CopyChildren(XmlDocument doc, XmlNode container,
bool deep)
969 for (XmlNode xmlNode = container.FirstChild; xmlNode !=
null; xmlNode = xmlNode.NextSibling)
971 AppendChildForLoad(xmlNode.CloneNode(deep), doc);
984 switch (xmlNode2.NodeType)
990 stringBuilder.
Append(xmlNode2.Value);
991 XmlNode xmlNode3 = NormalizeWinner(xmlNode, xmlNode2);
992 if (xmlNode3 == xmlNode)
1008 if (xmlNode !=
null)
1015 if (xmlNode !=
null && stringBuilder.
Length > 0)
1023 if (firstNode ==
null)
1059 public virtual bool Supports(
string feature,
string version)
1061 if (
string.Compare(
"XML", feature,
StringComparison.OrdinalIgnoreCase) == 0 && (version ==
null || version ==
"1.0" || version ==
"2.0"))
1068 internal static bool HasReadOnlyParent(
XmlNode n)
1106 return new XmlChildEnumerator(
this);
1113 return new XmlChildEnumerator(
this);
1120 if (xmlNode.FirstChild ==
null)
1124 builder.
Append(xmlNode.InnerText);
1129 xmlNode.AppendChildText(builder);
1136 public abstract void WriteTo(XmlWriter w);
1147 while (xmlNode !=
null)
1160 string namespaceOfPrefixStrict = GetNamespaceOfPrefixStrict(prefix);
1161 if (namespaceOfPrefixStrict ==
null)
1163 return string.Empty;
1165 return namespaceOfPrefixStrict;
1168 internal string GetNamespaceOfPrefixStrict(
string prefix)
1171 if (document !=
null)
1178 XmlNode xmlNode =
this;
1179 while (xmlNode !=
null)
1183 XmlElement xmlElement = (XmlElement)xmlNode;
1184 if (xmlElement.HasAttributes)
1186 XmlAttributeCollection attributes = xmlElement.Attributes;
1187 if (prefix.Length == 0)
1189 for (
int i = 0; i < attributes.Count; i++)
1191 XmlAttribute xmlAttribute = attributes[i];
1192 if (xmlAttribute.Prefix.Length == 0 && Ref.Equal(xmlAttribute.LocalName, document.strXmlns))
1194 return xmlAttribute.Value;
1200 for (
int j = 0; j < attributes.Count; j++)
1202 XmlAttribute xmlAttribute2 = attributes[j];
1203 if (
Ref.Equal(xmlAttribute2.Prefix, document.strXmlns))
1205 if (
Ref.Equal(xmlAttribute2.LocalName, prefix))
1207 return xmlAttribute2.Value;
1210 else if (
Ref.Equal(xmlAttribute2.Prefix, prefix))
1212 return xmlAttribute2.NamespaceURI;
1217 if (
Ref.Equal(xmlNode.Prefix, prefix))
1219 return xmlNode.NamespaceURI;
1221 xmlNode = xmlNode.ParentNode;
1225 xmlNode = ((xmlNode.NodeType !=
XmlNodeType.Attribute) ? xmlNode.ParentNode : ((XmlAttribute)xmlNode).OwnerElement);
1228 if (
Ref.Equal(document.strXml, prefix))
1230 return document.strReservedXml;
1232 if (
Ref.Equal(document.strXmlns, prefix))
1234 return document.strReservedXmlns;
1245 string prefixOfNamespaceStrict = GetPrefixOfNamespaceStrict(namespaceURI);
1246 if (prefixOfNamespaceStrict ==
null)
1248 return string.Empty;
1250 return prefixOfNamespaceStrict;
1253 internal string GetPrefixOfNamespaceStrict(
string namespaceURI)
1256 if (document !=
null)
1260 while (xmlNode !=
null)
1268 for (
int i = 0; i < attributes.Count; i++)
1271 if (xmlAttribute.
Prefix.Length == 0)
1273 if (Ref.Equal(xmlAttribute.
LocalName, document.strXmlns) && xmlAttribute.
Value == namespaceURI)
1275 return string.Empty;
1278 else if (Ref.Equal(xmlAttribute.
Prefix, document.strXmlns))
1280 if (xmlAttribute.
Value == namespaceURI)
1287 return xmlAttribute.
Prefix;
1302 if (
Ref.Equal(document.strReservedXml, namespaceURI))
1304 return document.strXml;
1306 if (
Ref.Equal(document.strReservedXmlns, namespaceURI))
1308 return document.strXmlns;
1314 internal virtual void SetParent(XmlNode node)
1326 internal virtual void SetParentForLoad(XmlNode node)
1331 internal static void SplitName(
string name, out
string prefix, out
string localName)
1333 int num = name.IndexOf(
':');
1334 if (-1 == num || num == 0 || name.Length - 1 == num)
1336 prefix =
string.Empty;
1341 prefix = name.Substring(0, num);
1342 localName = name.Substring(num + 1);
1346 internal virtual XmlNode FindChild(
XmlNodeType type)
1358 internal virtual XmlNodeChangedEventArgs GetEventArgs(XmlNode node, XmlNode oldParent, XmlNode newParent,
string oldValue,
string newValue,
XmlNodeChangedAction action)
1361 if (ownerDocument !=
null)
1363 if (!ownerDocument.IsLoading && ((newParent !=
null && newParent.IsReadOnly) || (oldParent !=
null && oldParent.IsReadOnly)))
1365 throw new InvalidOperationException(Res.GetString(
"Xdom_Node_Modify_ReadOnly"));
1367 return ownerDocument.GetEventArgs(node, oldParent, newParent, oldValue, newValue, action);
1372 internal virtual void BeforeEvent(XmlNodeChangedEventArgs args)
1380 internal virtual void AfterEvent(XmlNodeChangedEventArgs args)
1388 internal virtual string GetXPAttribute(
string localName,
string namespaceURI)
1390 return string.Empty;
1393 internal static void NestTextNodes(XmlNode prevNode, XmlNode nextNode)
1395 nextNode.parentNode = prevNode;
1398 internal static void UnnestTextNodes(XmlNode prevNode, XmlNode nextNode)
1400 nextNode.parentNode = prevNode.ParentNode;
virtual XPathNodeIterator Select(string xpath)
Selects a node set, using the specified XPath expression.
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
Represents an XML document. You can use this class to load, validate, edit, add, and position XML in ...
virtual string OuterXml
Gets the markup containing this node and all its child nodes.
abstract string LocalName
Gets the local name of the node, when overridden in a derived class.
object Clone()
Creates a new object that is a copy of the current instance.
IEnumerator GetEnumerator()
Get an enumerator that iterates through the child nodes in the current node.
Defines the post-schema-validation infoset of a validated XML node.
virtual XmlNode PreviousText
Gets the text node that immediately precedes this node.
virtual XmlNode ParentNode
Gets the parent of this node (for nodes that can have parents).
Represents an ordered collection of nodes.
XmlNameTable NameTable
Gets the T:System.Xml.XmlNameTable associated with this implementation.
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
virtual XmlDocument OwnerDocument
Gets the T:System.Xml.XmlDocument to which this node belongs.
abstract void WriteTo(XmlWriter w)
Saves the current node to the specified T:System.Xml.XmlWriter, when overridden in a derived class.
Implements a T:System.IO.TextWriter for writing information to a string. The information is stored in...
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
virtual void Normalize()
Puts all XmlText nodes in the full depth of the sub-tree underneath this XmlNode into a "normal" form...
virtual XmlNode ReplaceChild(XmlNode newChild, XmlNode oldChild)
Replaces the child node oldChild with newChild node.
virtual XmlNode LastChild
Gets the last child of the node.
override XPathNavigator CreateNavigator()
Creates a new T:System.Xml.XPath.XPathNavigator object for navigating this document.
Represents an attribute. Valid and default values for the attribute are defined in a document type de...
Represents an entity reference node.
abstract void WriteContentTo(XmlWriter w)
Saves all the child nodes of the node to the specified T:System.Xml.XmlWriter, when overridden in a d...
virtual XmlNode InsertBefore(XmlNode newChild, XmlNode refChild)
Inserts the specified node immediately before the specified reference node.
XmlNode SelectSingleNode(string xpath)
Selects the first XmlNode that matches the XPath expression.
virtual bool IsReadOnly
Gets a value indicating whether the node is read-only.
XmlNodeType
Specifies the type of node.
virtual XmlNode PrependChild(XmlNode newChild)
Adds the specified node to the beginning of the list of child nodes for this node.
XPathNodeType
Defines the XPath node types that can be returned from the T:System.Xml.XPath.XPathNavigator class.
override XmlNode PreviousSibling
Gets the node immediately preceding this node.
virtual string NamespaceURI
Gets the namespace URI of this node.
virtual bool HasChildNodes
Gets a value indicating whether this node has any child nodes.
virtual string GetAttribute(string name)
Returns the value for the attribute with the specified name.
Provides data for the E:System.Xml.XmlDocument.NodeChanged, E:System.Xml.XmlDocument....
virtual XmlText CreateTextNode(string text)
Creates an T:System.Xml.XmlText with the specified text.
abstract string Get(char[] array, int offset, int length)
When overridden in a derived class, gets the atomized string containing the same characters as the sp...
override string NamespaceURI
Gets the namespace URI of this node.
Provides an accessor to the T:System.Xml.XPath.XPathNavigator class.
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
virtual XmlNode Clone()
Creates a duplicate of this node.
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
override string ToString()
Returns a string containing the characters written to the current StringWriter so far.
virtual bool HasAttribute(string name)
Determines whether the current node has an attribute with the specified name.
abstract void SetContext(XmlNamespaceManager nsManager)
When overridden in a derived class, specifies the T:System.Xml.XmlNamespaceManager object to use for ...
Gets the node immediately preceding or following this node.
XmlNodeChangedAction
Specifies the type of node change.
Provides a typed class that represents a compiled XPath expression.
virtual string BaseURI
Gets the base URI of the current node.
virtual string InnerXml
Gets or sets the markup representing only the child nodes of this node.
Resolves, adds, and removes namespaces to a collection and provides scope management for these namesp...
int Length
Gets or sets the length of the current T:System.Text.StringBuilder object.
virtual string Value
Gets or sets the value of the node.
Supports cloning, which creates a new instance of a class with the same value as an existing instance...
virtual bool HasAttributes
Gets a boolean value indicating whether the current node has any attributes.
virtual XPathNavigator CreateNavigator()
Creates an T:System.Xml.XPath.XPathNavigator for navigating this object.
IEnumerator GetEnumerator()
Returns an enumerator that iterates through a collection.
virtual bool Supports(string feature, string version)
Tests if the DOM implementation implements a specific feature.
virtual string Prefix
Gets or sets the namespace prefix of this node.
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
virtual XmlNodeList ChildNodes
Gets all the child nodes of the node.
The exception that is thrown when one of the arguments provided to a method is not valid.
override string LocalName
Gets the local name of the node.
abstract string Add(char[] array, int offset, int length)
When overridden in a derived class, atomizes the specified string and adds it to the XmlNameTable.
virtual XmlNode RemoveChild(XmlNode oldChild)
Removes specified child node.
abstract XmlNode CloneNode(bool deep)
Creates a duplicate of the node, when overridden in a derived class.
virtual XmlNode FirstChild
Gets the first child of the node.
Provides a cursor model for navigating and editing XML data.
virtual XmlNode AppendChild(XmlNode newChild)
Adds the specified node to the end of the list of child nodes, of this node.
virtual string GetNamespaceOfPrefix(string prefix)
Looks up the closest xmlns declaration for the given prefix that is in scope for the current node and...
Represents a collection of attributes that can be accessed by name or index.
The exception that is thrown when a method call is invalid for the object's current state.
XmlNodeList SelectNodes(string xpath, XmlNamespaceManager nsmgr)
Selects a list of nodes matching the XPath expression. Any prefixes found in the XPath expression are...
virtual string GetPrefixOfNamespace(string namespaceURI)
Looks up the closest xmlns declaration for the given namespace URI that is in scope for the current n...
virtual XmlNode NextSibling
Gets the node immediately following this node.
virtual void RemoveAll()
Removes all the child nodes and/or attributes of the current node.
XmlSpace
Specifies the current xml:space scope.
Provides information about a specific culture (called a locale for unmanaged code development)....
virtual string InnerText
Gets or sets the concatenated values of the node and all its child nodes.
virtual XPathExpression Compile(string xpath)
Compiles a string representing an XPath expression and returns an T:System.Xml.XPath....
virtual XmlNode InsertAfter(XmlNode newChild, XmlNode refChild)
Inserts the specified node immediately after the specified reference node.
override string Value
Gets or sets the value of the node.
override string Prefix
Gets or sets the namespace prefix of this node.
virtual XmlNode PreviousSibling
Gets the node immediately preceding this node.
override XmlAttributeCollection Attributes
Gets an T:System.Xml.XmlAttributeCollection containing the list of attributes for this node.
XmlNode SelectSingleNode(string xpath, XmlNamespaceManager nsmgr)
Selects the first XmlNode that matches the XPath expression. Any prefixes found in the XPath expressi...
XmlNodeList SelectNodes(string xpath)
Selects a list of nodes matching the XPath expression.
Represents a single node in the XML document.
abstract string Name
Gets the qualified name of the node, when overridden in a derived class.
Supports a simple iteration over a non-generic collection.
abstract XmlNodeType NodeType
Gets the type of the current node, when overridden in a derived class.
virtual IXmlSchemaInfo SchemaInfo
Gets the post schema validation infoset that has been assigned to this node as a result of schema val...
StringBuilder Remove(int startIndex, int length)
Removes the specified range of characters from this instance.
Encodes and decodes XML names, and provides methods for converting between common language runtime ty...
virtual XmlAttributeCollection Attributes
Gets an T:System.Xml.XmlAttributeCollection containing the attributes of this node.