Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XML DOM parentNode Property

XML DOM parentNode Property


Element Object Reference Element Object


Definition and Usage

The parentNode property returns the parent node of the specified element.

Syntax

elementNode.parentNode


Example

The following code snippet uses loadXMLDoc() to load "books.xml" Load into xmlDoc, and get the text node from the first Get the parent node of the element:</p>

Example

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName("title")[0];

parent=x.parentNode;

document.write("Parent node: " + parent.nodeName);

The code above will output:

Parent node: book

Try it »


Element Object Reference Element Object