This property is a Microsoft extension to the W3C DOM.
Object Attr CDATASection
CharacterData Comment Document DocumentFragment
DocumentType Entity EntityReference Node
Notation ProcessingInstruction Text
Object.nodeTypeString
The nodeTypeString property is read-only and returns the node type in string
form.
In the following example the code uses the 'staff.xml' file.
XML:
<staff>
<employee ssn="123456" pay="3">
<name>John Sullivan</name>
<position>&snrex;</position>
</employee>
<employee ssn="987654" pay="2">
<name>Mary Lopez</name>
<position>&pa;</position>
</employee>
</staff>
The code then uses the nodeTypeString property to display the node type of the first
child node of the root element (the 'employee' element), and the node type of that node's
first attribute.
Code (JavaScript):
xml_doc = new ActiveXObject("Microsoft.XMLDOM");
xml_doc.async = false;
xml_doc.load("staff.xml");
node = xml_doc.documentElement.firstChild;
document.write(node.nodeTypeString);
atts = node.attributes;
document.write("<br>" + atts[0].nodeTypeString);
Output:
element
attribute
|