class DOM_Attr : public DOM_Node

The DOM_Attr class refers to an attribute of an XML element

Inheritance:


Public

Constructors and assignment operators
DOM_Attr ()
Default constructor for DOM_Attr
DOM_Attr (const DOM_Attr &other)
Copy constructor
DOM_Attr& operator = (const DOM_Attr &other)
Assignment operator
DOM_Attr& operator = (const DOM_NullPtr *val)
Assignment operator
Destructor
~DOM_Attr ()
Destructor
Functions introduced in DOM Level 2.
DOM_Element getOwnerElement () const
The Element node this attribute is attached to or null if this attribute is not in use
Getter functions
DOMString getName () const
Returns the name of this attribute
bool getSpecified () const
Returns true if the attribute received its value explicitly in the XML document, or if a value was assigned programatically with the setValue function
DOMString getValue () const
Returns the value of the attribute
Setter functions
void setValue (const DOMString &value)
Sets the value of the attribute
void setSpecified (bool spec)
Sets the value of the SPECIFIED for this attribute

Inherited from DOM_Node:

Public

Cloning function.

DOM_Node cloneNode(bool deep) const
Returns a duplicate of this node

Destructor.

~DOM_Node()
Destructor for DOM_Node

Equality and Inequality operators.

bool operator == (const DOM_Node & other) const
The equality operator
bool operator == (const DOM_NullPtr *other) const
Compare with a pointer
bool operator != (const DOM_Node & other) const
The inequality operator
bool operator != (const DOM_NullPtr * other) const
Compare with a pointer

Functions to modify the DOM Node.

DOM_Node insertBefore(const DOM_Node &newChild, const DOM_Node &refChild)
Inserts the node newChild before the existing child node refChild
DOM_Node replaceChild(const DOM_Node &newChild, const DOM_Node &oldChild)
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node
DOM_Node removeChild(const DOM_Node &oldChild)
Removes the child node indicated by oldChild from the list of children, and returns it
DOM_Node appendChild(const DOM_Node &newChild)
Adds the node newChild to the end of the list of children of this node

Get functions.

DOMString getNodeName() const
The name of this node, depending on its type; see the table above
DOMString getNodeValue() const
Gets the value of this node, depending on its type
short getNodeType() const
An enum value representing the type of the underlying object
DOM_Node getParentNode() const
Gets the parent of this node
DOM_NodeList getChildNodes() const
Gets a NodeList that contains all children of this node
DOM_Node getFirstChild() const
Gets the first child of this node
DOM_Node getLastChild() const
Gets the last child of this node
DOM_Node getPreviousSibling() const
Gets the node immediately preceding this node
DOM_Node getNextSibling() const
Gets the node immediately following this node
DOM_NamedNodeMap getAttributes() const
Gets a NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise
DOM_Document getOwnerDocument() const
Gets the Document object associated with this node
void* getUserData() const
Return the user data pointer

Query functions.

bool hasChildNodes() const
This is a convenience method to allow easy determination of whether a node has any children
bool isNull() const
Test whether this node is null

Set functions.

void setNodeValue(const DOMString &nodeValue)
Sets the value of the node
void setUserData(void *p)
Set the user data for a node

Documentation

The DOM_Attr class refers to an attribute of an XML element. Typically the allowable values for the attribute are defined in a documenttype definition.

DOM_Attr objects inherit the DOM_Node interface, but since attributes are not actually child nodes of the elements they are associated with, the DOM does not consider them part of the document tree. Thus, the DOM_Node attributes parentNode, previousSibling, and nextSibling have a null value for DOM_Attr objects. The DOM takes the view that attributes are properties of elements rather than having a separate identity from the elements they are associated with; this should make it more efficient to implement such features as default attributes associated with all elements of a given type. Furthermore, attribute nodes may not be immediate children of a DocumentFragment. However, they can be associated with Element nodes contained within a DocumentFragment. In short, users of the DOM need to be aware that Attr nodes have some things in common with other objects inheriting the Node interface, but they also are quite distinct.

Constructors and assignment operators

DOM_Attr()
Default constructor for DOM_Attr. The resulting object does not refer to any Attribute; it will compare == to 0, and is similar to a null object reference variable in Java.

DOM_Attr(const DOM_Attr &other)
Copy constructor. Creates a new DOM_Attr that refers to the same underlying Attribute as the original. See also DOM_Node::clone(), which will copy an actual attribute, rather than just creating a new reference to the original attribute.
Parameters:
other - The source attribute reference object

DOM_Attr& operator = (const DOM_Attr &other)
Assignment operator
Parameters:
other - The source attribute object

DOM_Attr& operator = (const DOM_NullPtr *val)
Assignment operator. This overloaded variant is provided for the sole purpose of setting a DOM_Node reference variable to zero. Nulling out a reference variable in this way will decrement the reference count on the underlying Node object that the variable formerly referenced. This effect is normally obtained when reference variable goes out of scope, but zeroing them can be useful for global instances, or for local instances that will remain in scope for an extended time, when the storage belonging to the underlying node needs to be reclaimed.
Parameters:
val. - Only a value of 0, or null, is allowed.

Destructor

~DOM_Attr()
Destructor. The object being destroyed is a reference to the Attribute "node", not the underlying attribute itself.

Getter functions

DOMString getName() const
Returns the name of this attribute

bool getSpecified() const
Returns true if the attribute received its value explicitly in the XML document, or if a value was assigned programatically with the setValue function. Returns false if the attribute value came from the default value declared in the document's DTD.

DOMString getValue() const
Returns the value of the attribute. The value of the attribute is returned as a string. Character and general entity references are replaced with their values.

Setter functions

void setValue(const DOMString &value)
Sets the value of the attribute. A text node with the unparsed contents of the string will be created.
Parameters:
value - The value of the DOM attribute to be set

void setSpecified(bool spec)
Sets the value of the SPECIFIED for this attribute
Parameters:
spec - The boolean value to be set

Functions introduced in DOM Level 2.

DOM_Element getOwnerElement() const
The Element node this attribute is attached to or null if this attribute is not in use


This class has no child classes.

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

IBM Logo