XmlElement
XmlElement
XmlElement
XmlElement
Class
Definition
Encapsulates information specific to XML Element nodes.
public : sealed class XmlElement : IXmlElement, IXmlNode, IXmlNodeSelector, IXmlNodeSerializerpublic sealed class XmlElement : IXmlElement, IXmlNode, IXmlNodeSelector, IXmlNodeSerializerPublic NotInheritable Class XmlElement Implements IXmlElement, IXmlNode, IXmlNodeSelector, IXmlNodeSerializer// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Properties
Attributes Attributes Attributes Attributes
Gets the list of attributes of this node.
public : XmlNamedNodeMap Attributes { get; }public XmlNamedNodeMap Attributes { get; }Public ReadOnly Property Attributes As XmlNamedNodeMap// You can use this property in JavaScript.
The attributes for this node.
Remarks
This property returns a XmlNamedNodeMap for the nodes that can return attributes. These are the Element, Entity, and Notation nodes. This property is NULL for all other node types. For the valid node types, the XmlNamedNodeMap is always returned; when there are no attributes on the element, the list length is set to zero.
The following table describes the attributes for the node types.
| NodeType | Attributes |
|---|---|
| Element | IXmlNamedNodeMap |
| Attribute | NULL |
| Text | NULL |
| CDATASection | NULL |
| EntityReference | NULL |
| Entity | NULL |
| ProcessingInstruction | NULL |
| Comment | NULL |
| Document | NULL |
| DocumentType | NULL |
| DocumentFragment | NULL |
| Notation | NULL |
ChildNodes ChildNodes ChildNodes ChildNodes
Gets a list of children in the current node.
public : XmlNodeList ChildNodes { get; }public XmlNodeList ChildNodes { get; }Public ReadOnly Property ChildNodes As XmlNodeList// You can use this property in JavaScript.
The list of child nodes.
FirstChild FirstChild FirstChild FirstChild
Gets the first child node.
public : IXmlNode FirstChild { get; }public IXmlNode FirstChild { get; }Public ReadOnly Property FirstChild As IXmlNode// You can use this property in JavaScript.
InnerText InnerText InnerText InnerText
Gets the text from inside the XML.
public : PlatForm::String InnerText { get; set; }public string InnerText { get; set; }Public ReadWrite Property InnerText As string// You can use this property in JavaScript.
- Value
- PlatForm::String string string string
The text from inside the XML. Returns an empty string if there is no text.
LocalName LocalName LocalName LocalName
Gets the local name, which is the local part of a qualified name. This is called the local part in Namespaces in XML.
public : PlatForm::Object LocalName { get; }public object LocalName { get; }Public ReadOnly Property LocalName As object// You can use this property in JavaScript.
- Value
- PlatForm::Object object object object
The local name.
NamespaceUri NamespaceUri NamespaceUri NamespaceUri
Returns the Uniform Resource Identifier (URI) for the namespace.
public : PlatForm::Object NamespaceUri { get; }public object NamespaceUri { get; }Public ReadOnly Property NamespaceUri As object// You can use this property in JavaScript.
- Value
- PlatForm::Object object object object
The Uri for the namespace. This refers to the "uuu" portion of the namespace declaration xmlns:nnn="uuu".
NextSibling NextSibling NextSibling NextSibling
Gets the next sibling of the node in the parent's child list.
public : IXmlNode NextSibling { get; }public IXmlNode NextSibling { get; }Public ReadOnly Property NextSibling As IXmlNode// You can use this property in JavaScript.
NodeName NodeName NodeName NodeName
Returns the qualified name for attribute, document type, element, entity, or notation nodes. Returns a fixed string for all other node types.
public : PlatForm::String NodeName { get; }public string NodeName { get; }Public ReadOnly Property NodeName As string// You can use this property in JavaScript.
- Value
- PlatForm::String string string string
The qualified node name, which varies depending on the node type.
Remarks
This value depends on the NodeType property. The following table describes this dependency.
| NodeType | NodeName |
|---|---|
| Element | tagName |
| Attribute | name of attribute |
| Text | #text |
| CDATASection | #cdata-section |
| EntityReference | name of entity referenced |
| Entity | entity name |
| ProcessingInstruction | target |
| Comment | #comment |
| Document | #document |
| DocumentType | document type name |
| DocumentFragment | #document-fragment |
| Notation | notation name |
NodeType NodeType NodeType NodeType
Gets the XML Document Object Model (DOM) node type, which determines valid values and whether the node can have child nodes.
public : NodeType NodeType { get; }public NodeType NodeType { get; }Public ReadOnly Property NodeType As NodeType// You can use this property in JavaScript.
NodeValue NodeValue NodeValue NodeValue
Gets or sets the text associated with the node.
public : PlatForm::Object NodeValue { get; set; }public object NodeValue { get; set; }Public ReadWrite Property NodeValue As object// You can use this property in JavaScript.
- Value
- PlatForm::Object object object object
The text associated with the node.
Remarks
This value depends on the NodeType property. The following table describes this dependency.
| NodeType | NodeValue |
|---|---|
| Element | Null |
| Attribute | Value of attribute |
| Text | Content of the text node |
| CDATASection | Content of the CDATA Section |
| EntityReference | NULL |
| Entity | NULL |
| ProcessingInstruction | Entire content excluding the target |
| Comment | Content of the comment |
| Document | NULL |
| DocumentType | NULL |
| DocumentFragment | NULL |
| Notation | NULL |
OwnerDocument OwnerDocument OwnerDocument OwnerDocument
Returns the root of the document that contains the node.
public : XmlDocument OwnerDocument { get; }public XmlDocument OwnerDocument { get; }Public ReadOnly Property OwnerDocument As XmlDocument// You can use this property in JavaScript.
The parent document that represents the root of the document.
Prefix Prefix Prefix Prefix
Gets or sets the namespace prefix.
public : PlatForm::Object Prefix { get; set; }public object Prefix { get; set; }Public ReadWrite Property Prefix As object// You can use this property in JavaScript.
- Value
- PlatForm::Object object object object
The namespace prefix specified on the element, attribute, or entity reference. For example, for the element <xxx:yyy>, this property returns xxx. It returns an empty string, "", if no prefix is specified.
PreviousSibling PreviousSibling PreviousSibling PreviousSibling
Gets the previous sibling of the node in the parent's child list.
public : IXmlNode PreviousSibling { get; }public IXmlNode PreviousSibling { get; }Public ReadOnly Property PreviousSibling As IXmlNode// You can use this property in JavaScript.
Methods
AppendChild(IXmlNode) AppendChild(IXmlNode) AppendChild(IXmlNode) AppendChild(IXmlNode)
Appends a new child node as the last child of the node.
public : IXmlNode AppendChild(IXmlNode newChild)public IXmlNode AppendChild(IXmlNode newChild)Public Function AppendChild(newChild As IXmlNode) As IXmlNode// You can use this method in JavaScript.
The new child node to be appended to the end of the list of children of this node.
CloneNode(Boolean) CloneNode(Boolean) CloneNode(Boolean) CloneNode(Boolean)
Clones a new node.
public : IXmlNode CloneNode(bool deep)public IXmlNode CloneNode(Boolean deep)Public Function CloneNode(deep As Boolean) As IXmlNode// You can use this method in JavaScript.
- deep
- bool Boolean Boolean Boolean
A flag that indicates whether to recursively clone all nodes that are descendants of this node. If true, this method creates a clone of the complete tree below this node. If false, this method clones this node and its attributes only.
GetAttribute(String) GetAttribute(String) GetAttribute(String) GetAttribute(String)
Returns the value of the attribute.
public : PlatForm::String GetAttribute(PlatForm::String attributeName)public string GetAttribute(String attributeName)Public Function GetAttribute(attributeName As String) As string// You can use this method in JavaScript.
- attributeName
- PlatForm::String String String String
The name of the required attribute.
The string value of the attribute.
GetAttributeNode(String) GetAttributeNode(String) GetAttributeNode(String) GetAttributeNode(String)
Returns the attribute node.
public : XmlAttribute GetAttributeNode(PlatForm::String attributeName)public XmlAttribute GetAttributeNode(String attributeName)Public Function GetAttributeNode(attributeName As String) As XmlAttribute// You can use this method in JavaScript.
- attributeName
- PlatForm::String String String String
The name of the required attribute.
The returned attribute pointer.
GetAttributeNodeNS(Object, String) GetAttributeNodeNS(Object, String) GetAttributeNodeNS(Object, String) GetAttributeNodeNS(Object, String)
Returns the specified attribute from the specified namespace.
public : XmlAttribute GetAttributeNodeNS(PlatForm::Object namespaceUri, PlatForm::String localName)public XmlAttribute GetAttributeNodeNS(Object namespaceUri, String localName)Public Function GetAttributeNodeNS(namespaceUri As Object, localName As String) As XmlAttribute// You can use this method in JavaScript.
- namespaceUri
- PlatForm::Object Object Object Object
The namespace of the attribute to get.
- localName
- PlatForm::String String String String
The name of the attribute without the namespace prefix.
The returned attribute pointer.
GetAttributeNS(Object, String) GetAttributeNS(Object, String) GetAttributeNS(Object, String) GetAttributeNS(Object, String)
Returns the value of the attribute.
public : PlatForm::String GetAttributeNS(PlatForm::Object namespaceUri, PlatForm::String localName)public string GetAttributeNS(Object namespaceUri, String localName)Public Function GetAttributeNS(namespaceUri As Object, localName As String) As string// You can use this method in JavaScript.
- namespaceUri
- PlatForm::Object Object Object Object
The namespace of the attribute to get.
- localName
- PlatForm::String String String String
The name of the attribute without the namespace prefix.
The string value of the attribute.
GetElementsByTagName(String) GetElementsByTagName(String) GetElementsByTagName(String) GetElementsByTagName(String)
Returns a list of all descendant elements that match the supplied name.
public : XmlNodeList GetElementsByTagName(PlatForm::String tagName)public XmlNodeList GetElementsByTagName(String tagName)Public Function GetElementsByTagName(tagName As String) As XmlNodeList// You can use this method in JavaScript.
- tagName
- PlatForm::String String String String
The tag of the required elements.
The required elements. The list can be empty.
GetXml() GetXml() GetXml() GetXml()
Returns the XML representation of the node and all its descendants.
public : PlatForm::String GetXml()public string GetXml()Public Function GetXml() As string// You can use this method in JavaScript.
The XML representation of the node and all its descendants.
HasChildNodes() HasChildNodes() HasChildNodes() HasChildNodes()
Determines whether a node has children.
public : PlatForm::Boolean HasChildNodes()public bool HasChildNodes()Public Function HasChildNodes() As bool// You can use this method in JavaScript.
True if this node has children; otherwise false.
InsertBefore(IXmlNode, IXmlNode) InsertBefore(IXmlNode, IXmlNode) InsertBefore(IXmlNode, IXmlNode) InsertBefore(IXmlNode, IXmlNode)
Inserts a child node to the left of the specified node, or at the end of the list.
public : IXmlNode InsertBefore(IXmlNode newChild, IXmlNode referenceChild)public IXmlNode InsertBefore(IXmlNode newChild, IXmlNode referenceChild)Public Function InsertBefore(newChild As IXmlNode, referenceChild As IXmlNode) As IXmlNode// You can use this method in JavaScript.
The address of the new node to be inserted. The node passed here must be a valid child of the current XML DOM document node. For example, if the current node is an attribute, you cannot pass another attribute in the newChild parameter, because an attribute cannot have an attribute as a child. If newChild is a DOCUMENT_FRAGMENT node type, all its children are inserted in order before referenceChild.
If newChild is already in the tree, it is first removed before it is reinserted before the referenceChild node. Read-only nodes, such as NODE_DOCUMENT_TYPE and NODE_ENTITY nodes, cannot be passed in the newChild parameter.
The reference node. The node specified is where the newChild node is to be inserted to the left as the preceding sibling in the child list. The node passed here must be a either a child node of the current node or null. If the value is null, the newChild node is inserted at the end of the child list. If the referenceChild node is not a child of the current node, an error is returned.
Normalize() Normalize() Normalize() Normalize()
Normalizes all descendant elements by combining two or more adjacent text nodes into one unified text node.
public : void Normalize()public void Normalize()Public Function Normalize() As void// You can use this method in JavaScript.
RemoveAttribute(String) RemoveAttribute(String) RemoveAttribute(String) RemoveAttribute(String)
Removes or replaces the named attribute.
public : void RemoveAttribute(PlatForm::String attributeName)public void RemoveAttribute(String attributeName)Public Function RemoveAttribute(attributeName As String) As void// You can use this method in JavaScript.
- attributeName
- PlatForm::String String String String
The name of the attribute to be removed.
RemoveAttributeNode(XmlAttribute) RemoveAttributeNode(XmlAttribute) RemoveAttributeNode(XmlAttribute) RemoveAttributeNode(XmlAttribute)
Removes the specified attribute from this element.
public : XmlAttribute RemoveAttributeNode(XmlAttribute attributeNode)public XmlAttribute RemoveAttributeNode(XmlAttribute attributeNode)Public Function RemoveAttributeNode(attributeNode As XmlAttribute) As XmlAttribute// You can use this method in JavaScript.
- attributeNode
- XmlAttribute XmlAttribute XmlAttribute XmlAttribute
The attribute to be removed.
The removed attribute, if any.
RemoveAttributeNS(Object, String) RemoveAttributeNS(Object, String) RemoveAttributeNS(Object, String) RemoveAttributeNS(Object, String)
Removes the specified attribute from this element in the specified namespace.
public : void RemoveAttributeNS(PlatForm::Object namespaceUri, PlatForm::String localName)public void RemoveAttributeNS(Object namespaceUri, String localName)Public Function RemoveAttributeNS(namespaceUri As Object, localName As String) As void// You can use this method in JavaScript.
- namespaceUri
- PlatForm::Object Object Object Object
The namespace of attribute to be removed.
- localName
- PlatForm::String String String String
The name of the attribute without the namespace prefix.
RemoveChild(IXmlNode) RemoveChild(IXmlNode) RemoveChild(IXmlNode) RemoveChild(IXmlNode)
Removes the specified child node from the list of children and returns it.
public : IXmlNode RemoveChild(IXmlNode childNode)public IXmlNode RemoveChild(IXmlNode childNode)Public Function RemoveChild(childNode As IXmlNode) As IXmlNode// You can use this method in JavaScript.
The child node to be removed from the list of children of this node.
ReplaceChild(IXmlNode, IXmlNode) ReplaceChild(IXmlNode, IXmlNode) ReplaceChild(IXmlNode, IXmlNode) ReplaceChild(IXmlNode, IXmlNode)
Replaces the specified old child node with the supplied new child node.
public : IXmlNode ReplaceChild(IXmlNode newChild, IXmlNode referenceChild)public IXmlNode ReplaceChild(IXmlNode newChild, IXmlNode referenceChild)Public Function ReplaceChild(newChild As IXmlNode, referenceChild As IXmlNode) As IXmlNode// You can use this method in JavaScript.
The new child that is to replace the old child. If null, the referenceChild parameter is removed without a replacement.
The old child that is to be replaced by the new child.
SelectNodes(String) SelectNodes(String) SelectNodes(String) SelectNodes(String)
Applies the specified pattern-matching operation to this node's context and returns the list of matching nodes as an XmlNodeList.
public : XmlNodeList SelectNodes(PlatForm::String xpath)public XmlNodeList SelectNodes(String xpath)Public Function SelectNodes(xpath As String) As XmlNodeList// You can use this method in JavaScript.
- xpath
- PlatForm::String String String String
Specifies an XPath expression.
The collection of nodes selected by applying the given pattern-matching operation. If no nodes are selected, this method returns an empty collection.
SelectNodesNS(String, Object) SelectNodesNS(String, Object) SelectNodesNS(String, Object) SelectNodesNS(String, Object)
Applies the specified pattern-matching operation to this node's context and returns the list of matching nodes as an XmlNodeList.
public : XmlNodeList SelectNodesNS(PlatForm::String xpath, PlatForm::Object namespaces)public XmlNodeList SelectNodesNS(String xpath, Object namespaces)Public Function SelectNodesNS(xpath As String, namespaces As Object) As XmlNodeList// You can use this method in JavaScript.
- xpath
- PlatForm::String String String String
Specifies an XPath expression.
- namespaces
- PlatForm::Object Object Object Object
Contains a string that specifies namespaces for use in XPath expressions when it is necessary to define new namespaces externally. Namespaces are defined in the XML style, as a space-separated list of namespace declaration attributes. You can use this property to set the default namespace as well.
The collection of nodes selected by applying the given pattern-matching operation. If no nodes are selected, returns an empty collection.
Remarks
Prefixes in the query are resolved using the specified namespace declarations.
SelectSingleNode(String) SelectSingleNode(String) SelectSingleNode(String) SelectSingleNode(String)
Applies the specified pattern-matching operation to this node's context and returns the first matching node.
public : IXmlNode SelectSingleNode(PlatForm::String xpath)public IXmlNode SelectSingleNode(String xpath)Public Function SelectSingleNode(xpath As String) As IXmlNode// You can use this method in JavaScript.
- xpath
- PlatForm::String String String String
Specifies an XPath expression.
SelectSingleNodeNS(String, Object) SelectSingleNodeNS(String, Object) SelectSingleNodeNS(String, Object) SelectSingleNodeNS(String, Object)
Applies the specified pattern-matching operation to this node's context and returns the first matching node.
public : IXmlNode SelectSingleNodeNS(PlatForm::String xpath, PlatForm::Object namespaces)public IXmlNode SelectSingleNodeNS(String xpath, Object namespaces)Public Function SelectSingleNodeNS(xpath As String, namespaces As Object) As IXmlNode// You can use this method in JavaScript.
- xpath
- PlatForm::String String String String
Specifies an XPath expression.
- namespaces
- PlatForm::Object Object Object Object
Contains a string that specifies the namespaces to use in XPath expressions when it is necessary to define new namespaces externally. Namespaces are defined in the XML style, as a space-separated list of namespace declaration attributes. You can use this property to set the default namespace as well.
The first node that matches the given pattern-matching operation. If no nodes match the expression, this method returns a null value.
Remarks
Prefixes in the query are resolved using the specified namespace declarations.
SetAttribute(String, String) SetAttribute(String, String) SetAttribute(String, String) SetAttribute(String, String)
Sets the value of the named attribute.
public : void SetAttribute(PlatForm::String attributeName, PlatForm::String attributeValue)public void SetAttribute(String attributeName, String attributeValue)Public Function SetAttribute(attributeName As String, attributeValue As String) As void// You can use this method in JavaScript.
- attributeName
- PlatForm::String String String String
The name of the required attribute.
- attributeValue
- PlatForm::String String String String
The new value for the attribute.
SetAttributeNode(XmlAttribute) SetAttributeNode(XmlAttribute) SetAttributeNode(XmlAttribute) SetAttributeNode(XmlAttribute)
Sets or updates the supplied attribute node on this element.
public : XmlAttribute SetAttributeNode(XmlAttribute newAttribute)public XmlAttribute SetAttributeNode(XmlAttribute newAttribute)Public Function SetAttributeNode(newAttribute As XmlAttribute) As XmlAttribute// You can use this method in JavaScript.
- newAttribute
- XmlAttribute XmlAttribute XmlAttribute XmlAttribute
A pointer to the new attribute.
The returned pointer to the previous attribute (if any) with the same name.
SetAttributeNodeNS(XmlAttribute) SetAttributeNodeNS(XmlAttribute) SetAttributeNodeNS(XmlAttribute) SetAttributeNodeNS(XmlAttribute)
Sets or updates the supplied attribute node on this element. If you are not using any namespaces, then use the SetAttributeNode method.
public : XmlAttribute SetAttributeNodeNS(XmlAttribute newAttribute)public XmlAttribute SetAttributeNodeNS(XmlAttribute newAttribute)Public Function SetAttributeNodeNS(newAttribute As XmlAttribute) As XmlAttribute// You can use this method in JavaScript.
- newAttribute
- XmlAttribute XmlAttribute XmlAttribute XmlAttribute
The node to add to the collection.
Note
You set the namespace when you create the node using the CreateAttributeNS method.
The attribute successfully added to the collection. If Null, no object is created.
SetAttributeNS(Object, String, String) SetAttributeNS(Object, String, String) SetAttributeNS(Object, String, String) SetAttributeNS(Object, String, String)
Sets the value of the named attribute in the given namespace.
public : void SetAttributeNS(PlatForm::Object namespaceUri, PlatForm::String qualifiedName, PlatForm::String value)public void SetAttributeNS(Object namespaceUri, String qualifiedName, String value)Public Function SetAttributeNS(namespaceUri As Object, qualifiedName As String, value As String) As void// You can use this method in JavaScript.
- namespaceUri
- PlatForm::Object Object Object Object
The namespace of the attribute being set.
- qualifiedName
- PlatForm::String String String String
The name of the attribute being set.
- value
- PlatForm::String String String String
The new value for the attribute.