Latest web development tutorials

XML DOM parentNode property

Element Object Reference Element object

Definition and Usage

parentNode property returns the parent node of the specified element.

grammar

elementNode.parentNode

Examples

The following code fragment uses loadXMLDoc () to " the Books.xml " into xmlDoc, and the first <title> element obtained from the parent node in "books.xml":

Examples

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