XML DOM » Node » nodeTypeString

Compability: Internet Explorer

Syntax:
node.nodeTypeString

This property is read-only and returns the node type in string form.

Examples

Code:
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>

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
Explanation:

In the following example the code opens the 'staff.xml' file and 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.

Language(s): JavaScript XML