This is a read-only property that returns the parent node of all nodes except Document, DocumentFragment and Attr, which cannot have parent nodes.
Also, a node that is newly-created and not yet added to a tree, or one that has been removed from a tree cannot have a parent node either.
XML:
<States>
<State ref="FL">
<name>Florida</name>
<capital>Tallahassee</capital>
</State>
<State ref="IA">
<name>Iowa</name>
<capital>Des Moines</capital>
</State>
</States>
JavaScript:
var xml_doc = new
ActiveXObject("Microsoft.XMLDOM");
xml_doc.async = false;
xml_doc.load("states.xml");
var n = xml_doc.documentElement.firstChild;
document.write(n.nodeName);
var p_node = n.parentNode;
document.write("<br>" + p_node.nodeName);
State
States
This example first gets the firstChild of the root node of the 'states.xml' file and then that node's parent node (the root node). It displays the node names of both.