XML DOM specified property
Definition and usage
If the attribute value is set in the document, the specified property returns true, and if it is the default value in DTD/Schema, it returns false.
Syntax:
attrObject.specified
Instance
In all examples, we will use the XML file books.xml, and the JavaScript function loadXMLDoc().
The following code snippet displays 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].specified
);
document.write("<br />");
}
The output of the above code is:
true true true true