Name
Document
Synopsis
This interface represents a DOM document, and
an object that implements this interface serves as the root of a DOM
document tree. Most of the methods defined by the Document interface
are “factory methods” that are used
to create various types of nodes that can be inserted into this
document. Note that there are two versions of the methods for
creating attributes and elements. The methods with
“NS” in their name are
namespace-aware and require the attribute or element name to be
specified as a combination of a namespace URI and a local name.
You’ll notice that throughout the
DOM API, methods with
“NS” in their names are
namespace-aware. Other important methods include the following:
getElementsByTagName( ) and its namespace-aware
variant getElementsByTagNameNS( ) search the
document tree for Element nodes that have the
specified tag name and return a NodeList
containing those matching nodes. The Element
interface defines methods by the same names that search only within
the subtree defined by an Element.
getElementById( ) is a related method that
searches the document tree for a single element with the specified
unique value for an ID attribute. This is useful
when you use an ID attribute to uniquely identify
certain tags within an XML document. Note that this method does not
search for attributes that are named
“id” or
“ID”. It searches for attributes
whose XML type (as declared in the document’s DTD)
is ID. Such attributes are often named “id”, but this is ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access