Xmlnode_Object GetAttribute Method

Returns a String containing the value of an existing attribute of the current node.

… xmlnode_object.GetAttribute(attribute)

Prerequisites

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

Parameters

attribute

A required String expression that specifies the name of the attribute to be accessed.

Remarks

This is a convenience method that finds a named attribute and returns the value of the attribute. The attribute must be an immediate child of the current node.

If the name is not found, an exception is thrown.

Examples

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

See Also

XML Classes | xmlnode_object.GetAttributeNode | xmlnode_object.GetElement | xmlnode_object.SetAttribute