class DOM_Element : public DOM_Node
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
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_Elementnodes. Assume the following XML document:<elementExample id="demo"> <subelement1/> <subelement2><subsubelement/></subelement2> </elementExample>When represented using DOM, the top node is an
DOM_Elementnode for "elementExample", which contains two childDOM_Elementnodes, one for "subelement1" and one for "subelement2". "subelement1" contains no child nodes.Elements may have attributes associated with them; since the
DOM_Elementinterface inherits fromDOM_Node, the genericDOM_Nodeinterface methodgetAttributesmay be used to retrieve the set of all attributes for an element. There are methods on theDOM_Elementinterface to retrieve either anDOM_Attrobject by name or an attribute value by name. In XML, where an attribute value may contain entity references, anDOM_Attrobject 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)
DOM_Attr value as a string, or an empty string if
that attribute does not have a specified or default value.
null or an empty
string, this method behaves like getAttribute.
void setAttributeNS(const DOMString &namespaceURI, const DOMString &qualifiedName, const DOMString &value)
qualifiedName parameter,
and its value is changed to be that of 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 a 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.null or an empty
string, this method behaves like setAttribute.
localName - The local name of the
attribute to create or alter.
value - The value to set in string form.
void removeAttributeNS(const DOMString &namespaceURI, const DOMString &localName)
null or an empty
string, this method behaves like removeAttribute.
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.
null or an empty
string, this method behaves like getAttributeNode.
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 previously existing DOM_Attr node is
returned, otherwise null is returned.
DOM_Attr node to add to the attribute list.
When the node has no namespaceURI, this method behaves like
setAttributeNode.
DOM_NodeList getElementsByTagNameNS(const DOMString &namespaceURI, const DOMString &localName) const
DOM_NodeList of all the DOM_Elements
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
Elements.
null or an empty string, this
method behaves like getElementsByTagName.
localName - The local name of the
elements to match on. The special value "*" matches all local names.
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 |
|
generated by doc++