Java Reference
In-Depth Information
This is where the DOM differs from the BOM quite extensively. The BOM objects have names
that relate to a specific part of the browser, such as the window object, or the forms and images
collections. As mentioned earlier, to be able to navigate in the web page as though it were a
tree, you have to do it abstractly. You can have no prior knowledge of the structure of the page;
everything ultimately is just a node. To move around from HTML element to HTML element,
or element to attribute, you have to go from node to node. This also means you can add, replace,
or remove parts of your web page without affecting the structure as a whole, because you're just
changing nodes. This is why you have three rather obscure‐sounding objects that represent your
tree structure.
I've already mentioned that the top of your tree structure is the root node, and that the root node
contains the DTD and root element. Therefore, you need more than just these three objects to
represent your document. In fact, there are different objects to represent the different types of nodes
on the tree.
high‐Level DOM Objects
Because everything in the DOM is a node, it's no wonder that nodes come in a variety of types.
Is the node an element, an attribute, or just plaintext? The Node object has different objects to
represent each possible type of node. The following is a complete list of all the different node type
objects that can be accessed via the DOM. A lot of them won't concern you in this topic, because
they're better suited for XML documents and not HTML documents, but you should notice that
your three main types of nodes, namely element, attribute, and text, are all covered.
objeCt
desCription
The root node of the document
Document
The DTD or schema type of the XML document
DocumentType
A temporary storage space for parts of the document
DocumentFragment
A reference to an entity in the XML document
EntityReference
An element in the document
Element
An attribute of an element in the document
Attr
A processing instruction
ProcessingInstruction
A comment in an XML document or HTML document
Comment
Text that must form a child node of an element
Text
A CDATA section within the XML document
CDATASection
An unparsed entity in the DTD
Entity
A notation declared within a DTD
Notation
We won't go over most of these objects in this chapter.
 
Search WWH ::




Custom Search