Database Journal: The Knowledge Center for Database Professionals
|
|
|
A WebDeveloper.com Feature
|
Understanding the DOM
Part 2
by Nate Zelnick
Nodes for Nerds
By "node" the DOM means a place in a tree that has some structural meaning. Since XML is hierarchical, the relationships between nodes can be expressed as a set of relationships between these nodes. The actual required structure is pretty fluid, though. While a document can only have one DOCUMENT interface because this is the top-level object on the hierarchical tree, everything else is fairly ad hoc.
Some node object types are really interfaces that can create one or more node object types that are contained within them. For instance, a Document is composed of exactly one Element and can also contain a ProcessingInstruction, a Comment or a DocumentType. Thus the Document interface must be able to create nodes for these types. A ProcessingInstruction is what’s called a leaf node, meaning it contains no other nodes and thus doesn’t create any other node objects.
A node that contains a node is in a parent-child relationship, with the containing node designated as the parent. Thus the Document element, as the top of the hierarchy, is the parent of the nodes directly under it, while those nodes are the parents of the nodes one level below them. Nodes on the same level—that is nodes that are both children of the same parent node—are called siblings. The node objects that a Document interface can create—Elements, ProcessingInstructions, Comments or DocumentTypes—are its children. If an Element contains another Element node object created through the Element interface, it is a child node of the Element that is a child of the Document.
[ Click here to move to the next part of the article ]
Contact the WebDeveloper.com® staff
Last modified:
Friday, 25-Feb-2011 12:28:06 EST
|
|
Refresh Daily
Join Editor-in-Chief David Fiedler
and find truth, justice, and a clue or two.
|