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 introduced in DOM Level 2.
| ||||||||||||
![]() | 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
DOM_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 name (nodeName
) or
null
if there is no such attribute.
nodeName
) of the attribute to retrieve.
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)
nodeName
) is already present
in the element, it is replaced by the new one.
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, the replaced
DOM_Attr
node is returned, otherwise null
is
returned.
DOM_Attr
node to add to the attribute list.
DOM_Attr
has a default value it is immediately replaced. The replacing attribute
has the same namespace URI and local name, as well as the original prefix,
when applicable.
oldAttr
is not an attribute
of the element.DOM_Attr
node that was removed.
DOM_Attr
node to remove from the attribute
list.
void removeAttribute(const DOMString &name)
To remove an attribute by local
name and namespace URI, use the removeAttributeNS
method.
"Experimental - subject to change"
DOM_Attr
value as a string, or an null
if
that attribute does not have a specified or default value.
"Experimental - subject to change"
"Experimental - subject to change"
"Experimental - subject to change"
"Experimental - subject to change"
"Experimental - subject to change" void setAttributeNS(const DOMString &namespaceURI, const DOMString &qualifiedName, const DOMString &value)
qualifiedName
, and
its value is changed to be the value
parameter. This value is
a simple string, it is not parsed as it is being set. So any markup (such
as syntax to be recognized as an entity reference) is treated as literal
text, and needs to be appropriately escaped by the implementation when it
is written out. In order to assign an attribute value that contains entity
references, the user must create an DOM_Attr
node plus any DOM_Text
and DOM_EntityReference
nodes, build the appropriate subtree, and use
setAttributeNodeNS
or setAttributeNode
to assign
it as the value of an attribute.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NAMESPACE_ERR: Raised if the qualifiedName
is
malformed, if the qualifiedName
has a prefix and the
namespaceURI
is null
or an empty string,
if the qualifiedName
has a prefix that is "xml" and the
namespaceURI
is different from
"http: * qualifiedName
has a prefix that is "xmlns" and the
namespaceURI
is different from
"http: * qualifiedName
is "xmlns" and the
namespaceURI
is different from
"http:
qualifiedName - The qualified name of the
attribute to create or alter.
value - The value to set in string form.
void removeAttributeNS(const DOMString &namespaceURI, const DOMString &localName)
localName - The local name of the
attribute to remove.
DOM_Attr getAttributeNodeNS(const DOMString &namespaceURI, const DOMString &localName) const
DOM_Attr
node by local name and namespace URI.
DOM_Attr
node with the specified attribute local
name and namespace URI or null
if there is no such attribute.
localName - The local name of the
attribute to retrieve.
DOM_Attr setAttributeNodeNS(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 local name and namespace URI,
the replaced DOM_Attr
node is
returned, otherwise null
is returned.
DOM_Attr
node to add to the attribute list.
DOM_NodeList getElementsByTagNameNS(const DOMString &namespaceURI, const DOMString &localName) const
DOM_NodeList
of all the DOM_Element
s
with a given local name and namespace URI in the order in which they
would be encountered in a preorder traversal of the
DOM_Document
tree, starting from this node.
DOM_NodeList
object containing all the matched
DOM_Element
s.
localName - The local name of the
elements to match on. The special value "*" matches all local names.
alphabetic index hierarchy of classes
Xerces-C XML Parser for C++ Version 1.1 |
|
generated by doc++