Document — Inherits Node
The Document
interface is the object representation of an entire XML document. It
contains all of the root elements, as well as the document type. The
contained child objects of the Document
have their ownerDocument
attribute associated with
this parent.
doctype
Contains the Document Type Declaration associated with the document. The value is read-only, and cannot be modified in DOM Level 2.
documentElement
Represents the root element of the document. As you work with the DOM, dealing with elements is a natural thing, and being able to quickly extract the root element of any document object is desirable.
implementation
createAttribute(
name
)
Creates an Attr
object with the
name
supplied. Support for
namespaces is provided with the createAttributeNS
method.
createAttributeNS(
namespaceURI, qualifiedName
)
Does essentially the same task as createAttribute(
name
)
, however it creates the attribute
with the given namespaceURI
.
createCDATASection(
data
)
Creates and returns a
CDATA
node section with the
supplied data.
createComment(
data
)
createDocumentFragment(
)
createElement(
tagname
)
Creates an element with the given element
tagname
. Returns an Element
object.
createElementNS(
namespaceURI, qualifiedName
)
Same as createElement
; however the
namespaceURI
is associated with the
element.
createEntityReference(
name
)
Creates and returns an EntityReference
object; may raise an
invalid character exception if illegal characters are
used.
createProcessingInstruction(
target, data
)
Creates and returns a ProcessingInstruction
node with the
supplied target
and
data
.
createTextNode(
data
)
Creates and returns a text node that contains
the text given by data
.
getElementById(
elementId
)
Returns an Element
object with the
corresponding ID. Returns None
if there is no such element.
Remember that ID attributes must be specified in the DTD.
Simply creating a tag such as <account id="234"/>
will not
cause it to be returned by this method unless the DTD included
assigns the attribute to be of the tokenized type ID.
Additionally, the DOMImplementation
object must be
aware of which attributes have been given the type ID.
Attributes of type ID must be unique within any given XML
document.
getElementsByTagName(
tagName
)
Returns a NodeList
containing all of the
elements matching tagName
. They are
returned in the order they were found when the original
document is parsed.
getElementsByTagNameNS(
namespaceURI, localName
)
Returns a NodeList
of the elements that match
both the localName
and
namespaceURI
.
importNode(
importedNode, deep
)
This method imports a node from another document
into the current one. The Node
has no parent. All attributes
and the namespace of the imported Node
are the same. Given the broad
variety of nodes that can be imported, certain rules or side
effects are applied.
Imported nodes that are Attributes (Attr
) have no owner element, and
all children are imported as well.
DocumentFragment
nodes have their children imported as well if the
deep
parameter is set to
true.
Document
nodes
are not imported since a Document
cannot contain another
Document
.
Element
nodes are
imported as expected, complete with attributes. If the
deep
parameter is true,
children of the element are imported as well.
EntityReference
nodes have only themselves copied, regardless of the
deep
parameter. If the entity
has a value definition, it is imported as well.
Notation
nodes
can be imported, but the DOM currently does not allow
modification of the DocumentType
.
ProcessingInstruction
nodes are
imported as expected, in their entirety. CharacterData
(including
CDATASection
and
Comment
nodes) are
copied as expected with their data
attribute.
18.224.44.53