By far the vast majority of objects (apart from text) that authors
encounter when traversing a document are DOM_Element
nodes
![]() | Constructors and assignment operator
| ||||||||
![]() | Destructor.
| ||||||||
![]() | Functions which modify the Element.
| ||||||||
![]() | Getter functions.
| ||||||||
![]() | Set functions.
|
Cloning function.
Constructors and assignment operators
Equality and Inequality operators.
Functions to modify the DOM Node.
newChild
before the existing child node
refChild
oldChild
with newChild
in the list of children, and returns the oldChild
node
oldChild
from the list
of children, and returns it
newChild
to the end of the list of children of
this node
Get functions.
NodeList
that contains all children of this node
NamedNodeMap
containing the attributes of this node (if it
is an Element
) or null
otherwise
Document
object associated with this node
Query functions.
By far the vast majority of objects (apart from text) that authors encounter when traversing a document areDOM_Element
nodes. Assume the following XML document:<elementExample id="demo"> <subelement1/> <subelement2><subsubelement/></subelement2> </elementExample>When represented using DOM, the top node is an
DOM_Element
node for "elementExample", which contains two childDOM_Element
nodes, one for "subelement1" and one for "subelement2". "subelement1" contains no child nodes.Elements may have attributes associated with them; since the
DOM_Element
interface inherits fromDOM_Node
, the genericDOM_Node
interface methodgetAttributes
may be used to retrieve the set of all attributes for an element. There are methods on theDOM_Element
interface to retrieve either anDOM_Attr
object by name or an attribute value by name. In XML, where an attribute value may contain entity references, anDOM_Attr
object should be retrieved to examine the possibly fairly complex sub-tree representing the attribute value. On the other hand, in HTML, where all attributes have simple string values, methods to directly access an attribute value can safely be used as a convenience.
New comment nodes are created by DOM_Document::createElement().
DOM_Element(const DOM_Element &other)
DOM_Element
that refers to the
same underlying actual element as the original.
DOM_Element& operator = (const DOM_Element &other)
DOM_Element& operator = (const DOM_NullPtr *val)
tagName
has
the value "elementExample"
. Note that this is
case-preserving in XML, as are all of the operations of the DOM.
DOMString getAttribute(const DOMString &name) const
DOM_Attr
value as a string, or the empty string if
that attribute does not have a specified or default value.
DOM_Attr getAttributeNode(const DOMString &name) const
DOM_Attr
node by name.
DOM_Attr
node with the specified attribute name or
null
if there is no such attribute.
DOM_NodeList getElementsByTagName(const DOMString &name) const
NodeList
of all descendant elements with a given
tag name, in the order in which they would be encountered in a preorder
traversal of the DOM_Element
tree.
DOM_Element
nodes.
DOM_Attr
node plus any Text
and
EntityReference
nodes, build the appropriate subtree, and
use setAttributeNode
to assign it as the value of an
attribute.
DOM_Attr setAttributeNode(DOM_Attr newAttr)
newAttr
was created from a
different document than the one that created the element.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
INUSE_ATTRIBUTE_ERR: Raised if newAttr
is already an
attribute of another DOM_Element
object. The DOM user must
explicitly clone DOM_Attr
nodes to re-use them in other
elements.newAttr
attribute replaces an existing
attribute with the same name, the previously existing
DOM_Attr
node is returned, otherwise null
is
returned.
DOM_Attr
node to add to the attribute list.
oldAttr
is not an attribute
of the element.DOM_Attr
node that was removed.
DOM_Attr
node to remove from the attribute
list. If the removed DOM_Attr
has a default value it is
immediately replaced.
void normalize()
Text
nodes in the full depth of the sub-tree
underneath this DOM_Element
into a "normal" form.
In the "normal" form
markup (e.g., tags, comments, processing instructions, CDATA sections,
and entity references) separates Text
nodes, i.e., there
are no adjacent Text
nodes. This can be used to ensure
that the DOM view of a document is the same as if it were saved and
re-loaded, and is useful when operations (such as XPointer lookups) that
depend on a particular document tree structure are to be used.
void removeAttribute(const DOMString &name)
alphabetic index hierarchy of classes
XML Parser for C++ 2.0 Copyright © IBM Corp, 1999 Center for Java Technology 10275 N. De Anza Blvd. Cupertino CA 95014 USA Email: xml4c@us.ibm.com |
|