XML DOM value attribute
Definition and usage
The value attribute returns the value of the attribute.
Syntax:
attrObject.value
Example
In all examples, we will use the XML file books.xml, and the JavaScript function loadXMLDoc().
The following code snippet shows the name and value of the category attribute:
xmlDoc=loadXMLDoc("/example/xdom/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("<br />");
}
The output of the above code is:
category = children category = cooking category = web category = web