The value property returns the value of an attribute.
attrObject.value
The following code fragment loads "books.xml" into xmlDoc using loadXMLDoc() and displays the name and value of the category attribute:
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("<br />"); }
Output:
category = COOKING category = CHILDREN category = WEB category = WEB
Return the name and value of an attribute
Jump to: Top of Page or HOME or Printer friendly page
W3Schools provides material for training only. We do not warrant the correctness of its contents. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright 1999-2008 by Refsnes Data. All Rights Reserved.