Parents and Children

The node relationships of the DOM are a direct manifestation of the [parent]/[children] relationships of the Infoset. The Node interface provides a set of attributes and methods that correspond to these two Infoset properties.

interface Node {
  readonly attribute Node         parentNode; 
  readonly attribute Node         firstChild;
  readonly attribute Node         lastChild;
  readonly attribute Node         previousSibling;
  readonly attribute Node         nextSibling;
  readonly attribute NodeList     childNodes;
  boolean                         hasChildNodes();
  readonly attribute Document     ownerDocument;
    :               :                  :
};

Figure 2.7 illustrates how these attributes relate to a given node in a document. Due to the Node interface's generality, some aspects of this interface may not be applicable for all ...

Get Essential XML: Beyond Markup now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.