XmlAttribute XmlAttribute XmlAttribute XmlAttribute Class

Definition

Represents an attribute of an XmlElement. Valid and default values for the attribute are defined in a document type definition (DTD) or schema.

public : sealed class XmlAttribute : IXmlAttribute, IXmlNode, IXmlNodeSelector, IXmlNodeSerializerpublic sealed class XmlAttribute : IXmlAttribute, IXmlNode, IXmlNodeSelector, IXmlNodeSerializerPublic NotInheritable Class XmlAttribute Implements IXmlAttribute, IXmlNode, IXmlNodeSelector, IXmlNodeSerializer// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Properties

Attributes Attributes Attributes Attributes

This method is not applicable to this class and will throw an exception.

public : XmlNamedNodeMap Attributes { get; }public XmlNamedNodeMap Attributes { get; }Public ReadOnly Property Attributes As XmlNamedNodeMap// You can use this property in JavaScript.
Value
XmlNamedNodeMap XmlNamedNodeMap XmlNamedNodeMap XmlNamedNodeMap

The attributes for this node.

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.
Value
XmlNodeList XmlNodeList XmlNodeList XmlNodeList

The list of child nodes.

Remarks

Child nodes can be a text or entity reference.

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.
Value
IXmlNode IXmlNode IXmlNode IXmlNode

The first child node. This property returns NULL if there are no children.

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.

LastChild LastChild LastChild LastChild

Gets the last child node.

public : IXmlNode LastChild { get; }public IXmlNode LastChild { get; }Public ReadOnly Property LastChild As IXmlNode// You can use this property in JavaScript.
Value
IXmlNode IXmlNode IXmlNode IXmlNode

The last child node. This property is NULL if there are no children.

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.

Name Name Name Name

Returns the attribute name.

public : PlatForm::String Name { get; }public string Name { get; }Public ReadOnly Property Name As string// You can use this property in JavaScript.
Value
PlatForm::String string string string

The attribute 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

This property is not applicable to this class and will always return null.

public : IXmlNode NextSibling { get; }public IXmlNode NextSibling { get; }Public ReadOnly Property NextSibling As IXmlNode// You can use this property in JavaScript.

Remarks

Attribute objects inherit the Node interface, but are not actually child nodes of the element they describe and are not considered part of the document tree. Therefore this property will always return null.

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.

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.
Value
NodeType NodeType NodeType NodeType

This property always returns value attributeNode.

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

On retrieval, the value of this attribute is returned as a string. Character and general entity references are replaced with their values.

On setting, this property creates a Text node with the unparsed contents of the string.

This value depends on the NodeType property. The following table describes this dependency.

NodeTypeNodeValue
ElementNull
AttributeValue of attribute
TextContent of the text node
CDATASectionContent of the CDATA Section
EntityReferenceNULL
EntityNULL
ProcessingInstructionEntire content excluding the target
CommentContent of the comment
DocumentNULL
DocumentTypeNULL
DocumentFragmentNULL
NotationNULL

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.
Value
XmlDocument XmlDocument XmlDocument XmlDocument

The parent document that represents the root of the document.

ParentNode ParentNode ParentNode ParentNode

This property is not applicable to this class and will throw an exception.

public : IXmlNode ParentNode { get; }public IXmlNode ParentNode { get; }Public ReadOnly Property ParentNode As IXmlNode// You can use this property in JavaScript.
Value
IXmlNode IXmlNode IXmlNode IXmlNode

The parent node.

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

This property is not applicable to this class and will throw an exception.

public : IXmlNode PreviousSibling { get; }public IXmlNode PreviousSibling { get; }Public ReadOnly Property PreviousSibling As IXmlNode// You can use this property in JavaScript.
Value
IXmlNode IXmlNode IXmlNode IXmlNode

The left sibling of this node.

Specified Specified Specified Specified

Gets a value that indicates whether the attribute is explicitly specified or derived from a default value in the document type definition (DTD) or schema.

public : PlatForm::Boolean Specified { get; }public bool Specified { get; }Public ReadOnly Property Specified As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

True if the attribute is explicitly specified; false if the attribute is derived from a default value.

Remarks

If you change the value of the attribute (even if it has the same value as the default value) then this property is automatically set to true. To re-specify the attribute as the default value from the DTD, you must delete the attribute. The implementation will then make a new attribute available with this property set to false and the default value (if one exists).

Value Value Value Value

Gets or sets the attribute value.

public : PlatForm::String Value { get; set; }public string Value { get; set; }Public ReadWrite Property Value As string// You can use this property in JavaScript.
Value
PlatForm::String string string string

The attribute value.

Remarks

When the value is retrieved, it is returned as a string. When the value is set, a text node is created with the unparsed contents of the string provided.

Methods

AppendChild(IXmlNode) AppendChild(IXmlNode) AppendChild(IXmlNode) AppendChild(IXmlNode)

This method is not applicable to this class and will throw an exception.

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.
Parameters
newChild
IXmlNode IXmlNode IXmlNode IXmlNode

The new child node to be appended to the end of the list of children of this node.

Returns

The new child node successfully appended to the list. If null, no object is created.

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.
Parameters
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.

Returns

The newly created clone node.

Remarks

If you want the cloned attribute to include the value of the attribute, you must use deep clone; otherwise only the attribute name is cloned.

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.
Returns
PlatForm::String string string string

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.
Returns
PlatForm::Boolean bool bool bool

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 child node 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.
Parameters
newChild
IXmlNode IXmlNode IXmlNode IXmlNode

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.

referenceChild
IXmlNode IXmlNode IXmlNode IXmlNode

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.

Returns

On success, the child node that was inserted. If null, no object is created.

Normalize() Normalize() Normalize() Normalize()

This method is not applicable to this class and will throw an exception.

public : void Normalize()public void Normalize()Public Function Normalize() As void// You can use this method in JavaScript.

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.
Parameters
childNode
IXmlNode IXmlNode IXmlNode IXmlNode

The child node to be removed from the list of children of this node.

Returns

The removed child node. If null, the childNode object is not removed.

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.
Parameters
newChild
IXmlNode IXmlNode IXmlNode IXmlNode

The new child that is to replace the old child. If null, the referenceChild parameter is removed without a replacement.

referenceChild
IXmlNode IXmlNode IXmlNode IXmlNode

The old child that is to be replaced by the new child.

Returns

The old child that is replaced. If null, no object is created.

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.
Parameters
xpath
PlatForm::String String String String

Specifies an XPath expression.

Returns

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.
Parameters
xpath
PlatForm::String String String String

Specifies an XPath expresssion.

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.

Returns

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.
Parameters
xpath
PlatForm::String String String String

Specifies an XPath expression.

Returns

The first node that matches the given pattern-matching operation. If no nodes match the expression, the method returns a null value.

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.
Parameters
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.

Returns

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.