Element.getAttributeNode(name)
The getAttributeNode method returns an Attr object of the
specified name, as opposed to just the string value returned by the
getAttribute method. If the named attribute connot
be found on this element, this method returns null.
The following example uses the 'states.xml' file and gets an Attr
object of 'ref' attribute of the last 'State' element. The code then displays its name and
value.
XML:
<States>
<State ref="FL" const="27">
<name>Florida</name>
<capital>Tallahassee</capital>
</State>
<State ref="IA" const="29">
<name>Iowa</name>
<capital>Des Moines</capital>
</State>
</States>
Code (VBScript):
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("states.xml")
Set LastState = objXMLDoc.documentElement.lastChild
Set RefAttr = LastState.getAttributeNode("ref")
document.write("Name: " & RefAttr.name)
document.write("<br>Value: " & RefAttr.value)
Output:
Name: ref
Value: IA