Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Xml.​XmlElement

Assembly: System.Xml.ReaderWriter

Inheritance: object → XmlNodeXmlLinkedNode → XmlElement

Implemented Interfaces

Represents an element.

Properties

Attributes
Gets an <see cref="T:System.Xml.XmlAttributeCollection" /> containing the list of attributes for this node.
public bool
HasAttributes
Gets a <see langword="boolean" /> value indicating whether the current node has any attributes.
public string
InnerText
Gets or sets the concatenated values of the node and all its children.
public string
InnerXml
Gets or sets the markup representing just the children of this node.
public bool
IsEmpty
Gets or sets the tag format of the element.
public string
LocalName
Gets the local name of the current node.
public string
Name
Gets the qualified name of the node.
public string
NamespaceURI
Gets the namespace URI of this node.
public XmlNode
NextSibling
Gets the <see cref="T:System.Xml.XmlNode" /> immediately following this element.
public XmlNodeType
NodeType
Gets the type of the current node.
public XmlDocument
OwnerDocument
Gets the <see cref="T:System.Xml.XmlDocument" /> to which this node belongs.
public XmlNode
ParentNode
Gets the parent of this node (for nodes that can have parents).
public string
Prefix
Gets or sets the namespace prefix of this node.
SchemaInfo
Gets the post schema validation infoset that has been assigned to this node as a result of schema validation.
public XmlNode
PreviousSibling
Gets the node immediately preceding this node.
public string
BaseURI
Gets the base URI of the current node.
public XmlNodeList
ChildNodes
Gets all the child nodes of the node.
public XmlNode
FirstChild
Gets the first child of the node.
public bool
HasChildNodes
Gets a value indicating whether this node has any child nodes.
public bool
IsReadOnly
Gets a value indicating whether the node is read-only.
public XmlElement
Item
public XmlElement
Item
public XmlNode
LastChild
Gets the last child of the node.
public string
OuterXml
Gets the markup containing this node and all its child nodes.
public XmlNode
PreviousText
Gets the text node that immediately precedes this node.
public string
Value
Gets or sets the value of the node.

Methods

public XmlNode
CloneNode​(bool deep)
Creates a duplicate of this node.
Returns The cloned node.
deep <see langword="true" /> to recursively clone the subtree under the specified node; <see langword="false" /> to clone only the node itself (and its attributes if the node is an <see langword="XmlElement" /> ).
public string
GetAttribute​(string name)
Returns the value for the attribute with the specified name.
Returns The value of the specified attribute. An empty string is returned if a matching attribute is not found or if the attribute does not have a specified or default value.
name The name of the attribute to retrieve. This is a qualified name. It is matched against the <see langword="Name" /> property of the matching node.
public string
GetAttribute​(string localName, string namespaceURI)
Returns the value for the attribute with the specified local name and namespace URI.
Returns The value of the specified attribute. An empty string is returned if a matching attribute is not found or if the attribute does not have a specified or default value.
localName The local name of the attribute to retrieve.
namespaceURI The namespace URI of the attribute to retrieve.
public XmlAttribute
GetAttributeNode​(string name)
Returns the <see langword="XmlAttribute" /> with the specified name.
Returns The specified <see langword="XmlAttribute" /> or <see langword="null" /> if a matching attribute was not found.
name The name of the attribute to retrieve. This is a qualified name. It is matched against the <see langword="Name" /> property of the matching node.
public XmlAttribute
GetAttributeNode​(string localName, string namespaceURI)
Returns the <see cref="T:System.Xml.XmlAttribute" /> with the specified local name and namespace URI.
Returns The specified <see langword="XmlAttribute" /> or <see langword="null" /> if a matching attribute was not found.
localName The local name of the attribute.
namespaceURI The namespace URI of the attribute.
public XmlNodeList
GetElementsByTagName​(string name)
Returns an <see cref="T:System.Xml.XmlNodeList" /> containing a list of all descendant elements that match the specified <see cref="P:System.Xml.XmlElement.Name" /> .
Returns An <see cref="T:System.Xml.XmlNodeList" /> containing a list of all matching nodes. The list is empty if there are no matching nodes.
name The name tag to match. This is a qualified name. It is matched against the <see langword="Name" /> property of the matching node. The asterisk (*) is a special value that matches all tags.
public XmlNodeList
GetElementsByTagName​(string localName, string namespaceURI)
Returns an <see cref="T:System.Xml.XmlNodeList" /> containing a list of all descendant elements that match the specified <see cref="P:System.Xml.XmlElement.LocalName" /> and <see cref="P:System.Xml.XmlElement.NamespaceURI" /> .
Returns An <see cref="T:System.Xml.XmlNodeList" /> containing a list of all matching nodes. The list is empty if there are no matching nodes.
localName The local name to match. The asterisk (*) is a special value that matches all tags.
namespaceURI The namespace URI to match.
public bool
HasAttribute​(string name)
Determines whether the current node has an attribute with the specified name.
Returns <see langword="true" /> if the current node has the specified attribute; otherwise, <see langword="false" /> .
name The name of the attribute to find. This is a qualified name. It is matched against the <see langword="Name" /> property of the matching node.
public bool
HasAttribute​(string localName, string namespaceURI)
Determines whether the current node has an attribute with the specified local name and namespace URI.
Returns <see langword="true" /> if the current node has the specified attribute; otherwise, <see langword="false" /> .
localName The local name of the attribute to find.
namespaceURI The namespace URI of the attribute to find.
public void
RemoveAll​()
Removes all specified attributes and children of the current node. Default attributes are not removed.
public void
RemoveAllAttributes​()
Removes all specified attributes from the element. Default attributes are not removed.
public void
RemoveAttribute​(string name)
Removes an attribute by name.
name The name of the attribute to remove. This is a qualified name. It is matched against the <see langword="Name" /> property of the matching node.
public void
RemoveAttribute​(string localName, string namespaceURI)
Removes an attribute with the specified local name and namespace URI. (If the removed attribute has a default value, it is immediately replaced).
localName The local name of the attribute to remove.
namespaceURI The namespace URI of the attribute to remove.
public XmlNode
RemoveAttributeAt​(int i)
Removes the attribute node with the specified index from the element. (If the removed attribute has a default value, it is immediately replaced).
Returns The attribute node removed or <see langword="null" /> if there is no node at the given index.
i The index of the node to remove. The first node has index 0.
public XmlAttribute
RemoveAttributeNode​(string localName, string namespaceURI)
Removes the <see cref="T:System.Xml.XmlAttribute" /> specified by the local name and namespace URI. (If the removed attribute has a default value, it is immediately replaced).
Returns The removed <see langword="XmlAttribute" /> or <see langword="null" /> if the <see langword="XmlElement" /> does not have a matching attribute node.
localName The local name of the attribute.
namespaceURI The namespace URI of the attribute.
public XmlAttribute
RemoveAttributeNode​(XmlAttribute oldAttr)
Removes the specified <see cref="T:System.Xml.XmlAttribute" /> .
Returns The removed <see langword="XmlAttribute" /> or <see langword="null" /> if <paramref name="oldAttr" /> is not an attribute node of the <see langword="XmlElement" /> .
oldAttr The <see langword="XmlAttribute" /> node to remove. If the removed attribute has a default value, it is immediately replaced.
public void
SetAttribute​(string name, string value)
Sets the value of the attribute with the specified name.
name The name of the attribute to create or alter. This is a qualified name. If the name contains a colon it is parsed into prefix and local name components.
value The value to set for the attribute.
public string
SetAttribute​(string localName, string namespaceURI, string value)
Sets the value of the attribute with the specified local name and namespace URI.
Returns The attribute value.
localName The local name of the attribute.
namespaceURI The namespace URI of the attribute.
value The value to set for the attribute.
public XmlAttribute
SetAttributeNode​(string localName, string namespaceURI)
Adds the specified <see cref="T:System.Xml.XmlAttribute" /> .
Returns The <see langword="XmlAttribute" /> to add.
localName The local name of the attribute.
namespaceURI The namespace URI of the attribute.
public XmlAttribute
SetAttributeNode​(XmlAttribute newAttr)
Adds the specified <see cref="T:System.Xml.XmlAttribute" /> .
Returns If the attribute replaces an existing attribute with the same name, the old <see langword="XmlAttribute" /> is returned; otherwise, <see langword="null" /> is returned.
newAttr The <see langword="XmlAttribute" /> node to add to the attribute collection for this element.
public void
WriteContentTo​(XmlWriter w)
Saves all the children of the node to the specified <see cref="T:System.Xml.XmlWriter" /> .
w The <see langword="XmlWriter" /> to which you want to save.
public void
WriteTo​(XmlWriter w)
Saves the current node to the specified <see cref="T:System.Xml.XmlWriter" /> .
w The <see langword="XmlWriter" /> to which you want to save.
public XmlNode
AppendChild​(XmlNode newChild)
Inherited from XmlNode
Adds the specified node to the end of the list of child nodes, of this node.
Returns The node added.
newChild The node to add. All the contents of the node to be added are moved into the specified location.
public XmlNode
Clone​()
Inherited from XmlNode
Creates a duplicate of this node.
Returns The cloned node.
CreateNavigator​()
Inherited from XmlNode
Creates an <see cref="T:System.Xml.XPath.XPathNavigator" /> for navigating this object.
Returns An <see langword="XPathNavigator" /> object used to navigate the node. The <see langword="XPathNavigator" /> is positioned on the node from which the method was called. It is not positioned on the root of the document.
GetEnumerator​()
Inherited from XmlNode
Gets an enumerator that iterates through the child nodes in the current node.
Returns An <see cref="T:System.Collections.IEnumerator" /> object that can be used to iterate through the child nodes in the current node.
public string
GetNamespaceOfPrefix​(string prefix)
Inherited from XmlNode
Looks up the closest xmlns declaration for the given prefix that is in scope for the current node and returns the namespace URI in the declaration.
Returns The namespace URI of the specified prefix.
prefix The prefix whose namespace URI you want to find.
public string
GetPrefixOfNamespace​(string namespaceURI)
Inherited from XmlNode
Looks up the closest xmlns declaration for the given namespace URI that is in scope for the current node and returns the prefix defined in that declaration.
Returns The prefix for the specified namespace URI.
namespaceURI The namespace URI whose prefix you want to find.
public XmlNode
InsertAfter​(XmlNode newChild, XmlNode refChild)
Inherited from XmlNode
Inserts the specified node immediately after the specified reference node.
Returns The node being inserted.
newChild The node to insert.
refChild The reference node. <paramref name="newChild" /> is placed after <paramref name="refChild" /> .
public XmlNode
InsertBefore​(XmlNode newChild, XmlNode refChild)
Inherited from XmlNode
Inserts the specified node immediately before the specified reference node.
Returns The node being inserted.
newChild The node to insert.
refChild The reference node. <paramref name="newChild" /> is placed before this node.
public void
Normalize​()
Inherited from XmlNode
Puts all XmlText nodes in the full depth of the sub-tree underneath this XmlNode into a "normal" form where only markup (that is, tags, comments, processing instructions, CDATA sections, and entity references) separates XmlText nodes, that is, there are no adjacent XmlText nodes.
public XmlNode
PrependChild​(XmlNode newChild)
Inherited from XmlNode
Adds the specified node to the beginning of the list of child nodes for this node.
Returns The node added.
newChild The node to add. All the contents of the node to be added are moved into the specified location.
public XmlNode
RemoveChild​(XmlNode oldChild)
Inherited from XmlNode
Removes specified child node.
Returns The node removed.
oldChild The node being removed.
public XmlNode
ReplaceChild​(XmlNode newChild, XmlNode oldChild)
Inherited from XmlNode
Replaces the child node <paramref name="oldChild" /> with <paramref name="newChild" /> node.
Returns The node replaced.
newChild The new node to put in the child list.
oldChild The node being replaced in the list.
public XmlNodeList
SelectNodes​(string xpath)
Inherited from XmlNode
Selects a list of nodes matching the XPath expression.
Returns An <see cref="T:System.Xml.XmlNodeList" /> containing a collection of nodes matching the XPath query.
xpath The XPath expression.
public XmlNodeList
SelectNodes​(string xpath, XmlNamespaceManager nsmgr)
Inherited from XmlNode
Selects a list of nodes matching the XPath expression. Any prefixes found in the XPath expression are resolved using the supplied <see cref="T:System.Xml.XmlNamespaceManager" /> .
Returns An <see cref="T:System.Xml.XmlNodeList" /> containing a collection of nodes matching the XPath query.
xpath The XPath expression. See XPath Examples.
nsmgr An <see cref="T:System.Xml.XmlNamespaceManager" /> to use for resolving namespaces for prefixes in the XPath expression.
public XmlNode
SelectSingleNode​(string xpath)
Inherited from XmlNode
Selects the first <see langword="XmlNode" /> that matches the XPath expression.
Returns The first <see langword="XmlNode" /> that matches the XPath query or <see langword="null" /> if no matching node is found.
xpath The XPath expression. See XPath Examples.
public XmlNode
SelectSingleNode​(string xpath, XmlNamespaceManager nsmgr)
Inherited from XmlNode
Selects the first <see langword="XmlNode" /> that matches the XPath expression. Any prefixes found in the XPath expression are resolved using the supplied <see cref="T:System.Xml.XmlNamespaceManager" /> .
Returns The first <see langword="XmlNode" /> that matches the XPath query or <see langword="null" /> if no matching node is found.
xpath The XPath expression. See XPath Examples.
nsmgr An <see cref="T:System.Xml.XmlNamespaceManager" /> to use for resolving namespaces for prefixes in the XPath expression.
public bool
Supports​(string feature, string version)
Inherited from XmlNode
Tests if the DOM implementation implements a specific feature.
Returns <see langword="true" /> if the feature is implemented in the specified version; otherwise, <see langword="false" /> . The following table describes the combinations that return <see langword="true" /> . <list type="table"> <listheader> <term> Feature</term> <description> Version</description> </listheader> <item> <term> XML</term> <description> 1.0</description> </item> <item> <term> XML</term> <description> 2.0</description> </item> </list>
feature The package name of the feature to test. This name is not case-sensitive.
version The version number of the package name to test. If the version is not specified (null), supporting any version of the feature causes the method to return true.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object