Xmlnode_Object GetAttributeNode Method

Returns the attribute node that is a child of the current node and has the specified attribute name.
… xmlnode_object.GetAttributeNode(attribute)

Prerequisites

The current node must be of type "element" or "document".

Parameters

attribute

An optional String expression that specifies the name of the attribute to be found. If the String is omitted or empty (""), the node for the first attribute is returned.

Remarks

This is a convenience method that finds an attribute node that has a specified attribute name. A new XmlNode object corresponding to the attribute is returned. If the attribute parameter is omitted or empty, the first attribute of the current node is returned. If there are no attributes for the current node, a Nothing object is returned. If the attribute parameter is specified but no matching attribute is found, an exception is thrown. The attribute node must be an immediate child of the current node.

Examples

Dim doc As XmlDoc
Dim
root As XmlNode
Dim
attr As XmlNode
doc = New XmlDoc("my_doc")
root = doc.DocumentElement
root.AddAttribute("color", "orange")
attr = root.GetAttributeNode("color")
Console.Writeline(attr.Name) 'Output is "color"

See Also

XML Classes | xmlnode_object.GetAttribute | xmlnode_object.GetElementNode | xmlnode_object.SetAttribute