Object Attr CDATASection
CharacterData Comment Document DocumentFragment
DocumentType Entity EntityReference Node
Notation ProcessingInstruction Text
Object.nodeType
The nodeType property is read-only and specifies the type of the node. For details
of the different node types see the
Node object.
The following example uses the 'states.xml' file and obtains the node types
of the document itself, and of the document's root node.
XML:
<States>
<State ref="FL">
<name>Florida</name>
<capital>Tallahassee</capital>
</State>
<State ref="IA">
<name>Iowa</name>
<capital>Des Moines</capital>
</State>
</States>
Code (JavaScript):
var xml_doc = new ActiveXObject("Microsoft.XMLDOM");
xml_doc.async = false;
xml_doc.load("states.xml");
var n = xml_doc;
document.write(n.nodeType);
n = xml_doc.documentElement;
document.write("<br>" + n.nodeType);
Output:
9 1
The node type enumerations 9 and 1 represent document and element nodes respectively
(see the Node object).
|