The childNodes property returns a NodeList of child nodes for the specified node.
Tip: You can use the length property to determine the number of child nodes, then you can loop through all child nodes and extract the info you want.
The childNodes property is supported in all major browsers.
Return Value: | A NodeList object representing a collection of nodes |
---|---|
DOM Version | Core Level 1 |
The following code fragment loads "books.xml" into xmlDoc using loadXMLDoc() and displays the child nodes of the XML document:
Output IE:
Output Firefox, Opera, Chrome, and Safari :
Display all child nodes of all the elements in the XML document