Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - DOM Reference

name Property (IXMLDOMAttribute)

Contains the attribute name.

[Script]

Script Syntax

strValue = oXMLDOMAttribute.name;

Example

The following script example creates an IXMLDOMAttribute object from an attribute of the first child of the root, and then displays the value of its name.

var xmlDoc = new ActiveXObject5.0("Msxml2.DOMDocument.5.0");
var root;
var objDOMatt;
xmlDoc.async = false;
if (xmlDoc.parseError.errorCode <> 0) {
   var myErr = xmlDoc.parseError;
   alert("You have error " + myErr.reason);
} else {
   xmlDoc.load("books.xml");
   root = xmlDoc.documentElement;
   objDOMatt = root.firstChild.attributes.item(0);
   alert(objDOMatt.name);
}
[Visual Basic]

Visual Basic Syntax

strValue = oXMLDOMAttribute.name

Example

The following Microsoft® Visual Basic® example creates an IXMLDOMAttribute object from an attribute of the first child of the root, and then displays the value of its name.

Dim xmlDoc As New Msxml2.DOMDocument50
Dim root As IXMLDOMElement
Dim objDOMatt As IXMLDOMAttribute
xmlDoc.async = False
xmlDoc.Load ("books.xml")
If (xmlDoc.parseError.errorCode <> 0) Then
   Dim myErr
   Set myErr = xmlDoc.parseError
   MsgBox("You have error " & myErr.reason)
Else
   Set root = xmlDoc.documentElement
   Set objDOMatt = root.firstChild.Attributes.Item(0)
   MsgBox objDOMatt.Name
End If
[C/C++]

C/C++ Syntax

HRESULT get_name(
    BSTR *attributeName);

Parameters

attributeName [out, retval]
Name of the attribute. The value is the same as the nodeName property of the IXMLDOMNode object.

C/C++ Return Values

S_OK
Value returned if successful.
S_FALSE
Value when returning Null.
E_INVALIDARG
Value returned if the attributeName parameter is Null.

Remarks

String. The property is read-only. It returns the name of the attribute. The value is the same as the nodeName property of the IXMLDOMNode.

To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

nodeName Property | IXMLDOMNode

Applies to: IXMLDOMAttribute