XML DOM xml attribute
Definition and usage
xml attribute returns the XML of the attribute.
Syntax:
attrObject.xml
Example
In all examples, we will use the XML file books.xml, as well as the JavaScript function loadXMLDoc().
The following code snippet shows the XML of the category attribute in the XML document:
xmlDoc=loadXMLDoc("/example/xdom/books.xml");
x=xmlDoc.getElementsByTagName('book');
for(i=0;i<x.length;i++)
{
document.write("<xmp>" + x.item(i).attributes[0].xml
+ "</xmp>");
document.write("<br />");
}
The output of the above code is:
category="children" category="cooking" category="web" category="web"