Latest web development tutorials

XML DOM name attribute

Attr Object Reference Attr objects

Definition and Usage

name property returns the name of the property.

grammar

attrObject.name


Examples

The following code fragment uses loadXMLDoc () to " the Books.xml " into xmlDoc, and displays the name and value of the category attribute:

Examples

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName('book');

for(i=0;i<x.length;i++)
{
document.write(x.item(i).attributes[0].name);
document.write(" = ");
document.write(x.item(i).attributes[0].value);
document.write("
");
}

Output:

category = COOKING
category = CHILDREN
category = WEB
category = WEB

try it"

Attr Object Reference Attr objects