Compability: Internet Explorer
This property returns the definition of the node in the DTD or schema.
The definition property is a read-only property that returns the definition of the node in the DTD or schema.The value depends on the nodeType property. The four relevant node types are as follows (all the other types return null):
xml_doc = new ActiveXObject("Microsoft.XMLDOM");
xml_doc.async = false;
xml_doc.load("albums.xml");
atts = xml_doc.documentElement.firstChild.attributes;
attr = atts[0];
def = attr.definition;
atts = def.attributes;
n_atts = atts.length;
for (i = 0; i < n_atts; i++)
document.write(atts[i].nodeName + "<br>");name
dt:type
required
To demonstrate how the definition property might be used, we will load the 'albums.xml' file, which has the following structure:
<Albums>
<Album ref="CD142" category="Folk">
<title>Boil The Breakfast Early</title>
<artist>The Chieftains</artist>
</Album>
</Albums>
Our code first creates a NamedNodeMap of all the attributes of the first 'Album' element. It then uses the definition property to create a Node object of the Schema definition of the first of these attributes (ref). Finally, the attributes of that node are copied to a NamedNodeMap, and the code iterates through the collection displaying the nodeName of each.