CopperSpice API  1.9.1
QDomAttr Class Reference

The QDomAttr class represents one attribute of a QDomElement. More...

Inheritance diagram for QDomAttr:

Public Methods

 QDomAttr ()
 QDomAttr (const QDomAttr &other)
QString name () const
QDomNode::NodeType nodeType () const
QDomAttr & operator= (const QDomAttr &other)
QDomElement ownerElement () const
void setValue (const QString &data)
bool specified () const
QString value () const
- Public Methods inherited from QDomNode
 QDomNode ()
 QDomNode (const QDomNode &other)
 ~QDomNode ()
QDomNode appendChild (const QDomNode &newChild)
QDomNamedNodeMap attributes () const
QDomNodeList childNodes () const
void clear ()
QDomNode cloneNode (bool deep=true) const
int columnNumber () const
QDomNode firstChild () const
QDomElement firstChildElement (const QString &tagName=QString ()) const
bool hasAttributes () const
bool hasChildNodes () const
QDomNode insertAfter (const QDomNode &newChild, const QDomNode &refChild)
QDomNode insertBefore (const QDomNode &newChild, const QDomNode &refChild)
bool isAttr () const
bool isCDATASection () const
bool isCharacterData () const
bool isComment () const
bool isDocument () const
bool isDocumentFragment () const
bool isDocumentType () const
bool isElement () const
bool isEntity () const
bool isEntityReference () const
bool isNotation () const
bool isNull () const
bool isProcessingInstruction () const
bool isSupported (const QString &feature, const QString &version) const
bool isText () const
QDomNode lastChild () const
QDomElement lastChildElement (const QString &tagName=QString ()) const
int lineNumber () const
QString localName () const
QDomNode namedItem (const QString &name) const
QString namespaceURI () const
QDomNode nextSibling () const
QDomElement nextSiblingElement (const QString &tagName=QString ()) const
QString nodeName () const
NodeType nodeType () const
QString nodeValue () const
void normalize ()
bool operator!= (const QDomNode &n) const
QDomNode & operator= (const QDomNode &other)
bool operator== (const QDomNode &n) const
QDomDocument ownerDocument () const
QDomNode parentNode () const
QString prefix () const
QDomNode previousSibling () const
QDomElement previousSiblingElement (const QString &tagName=QString ()) const
QDomNode removeChild (const QDomNode &oldChild)
QDomNode replaceChild (const QDomNode &newChild, const QDomNode &oldChild)
void save (QTextStream &stream, int indent, QDomNode::EncodingPolicy policy=QDomNode::EncodingFromDocument) const
void setNodeValue (const QString &value)
void setPrefix (const QString &prefix)
QDomAttr toAttr () const
QDomCDATASection toCDATASection () const
QDomCharacterData toCharacterData () const
QDomComment toComment () const
QDomDocument toDocument () const
QDomDocumentFragment toDocumentFragment () const
QDomDocumentType toDocumentType () const
QDomElement toElement () const
QDomEntity toEntity () const
QDomEntityReference toEntityReference () const
QDomNotation toNotation () const
QDomProcessingInstruction toProcessingInstruction () const
QDomText toText () const


class QDomDocument
class QDomElement
class QDomNode

Additional Inherited Members

- Public Types inherited from QDomNode
enum  EncodingPolicy
enum  NodeType

Detailed Description

The QDomAttr class represents one attribute of a QDomElement. As an example, the following XML produces an element with no children and two attributes.

<link href="" color="red" />

You can access the attributes of an element with code like this:

QDomElement e = < retrieve element here >
QDomAttr a = e.attributeNode("href");
cout << a.value() << endl; // prints ""
a.setValue(""); // change the node's attribute
QDomAttr a2 = e.attributeNode("href");
cout << a2.value() << endl; // prints ""

This example also shows that changing an attribute received from an element changes the attribute of the element. If you do not want to change the value of the element's attribute you must use cloneNode() to get an independent copy of the attribute.

QDomAttr can return the name() and value() of an attribute. An attribute's value is set with setValue(). If specified() returns true the value was set with setValue(). The node this attribute is attached to (if any) is returned by ownerElement().

For further information about the Document Object Model see and For a more general introduction of the DOM implementation see the QDomDocument documentation.

See also

Constructor & Destructor Documentation

QDomAttr::QDomAttr ( )

Constructs an empty attribute.

QDomAttr::QDomAttr ( const QDomAttr &  other)

Copy constructs a new QDomAttr from other.

Method Documentation

QString QDomAttr::name ( ) const

Returns the attribute's name.

QDomNode::NodeType QDomAttr::nodeType ( ) const

Returns AttributeNode.

QDomAttr & QDomAttr::operator= ( const QDomAttr &  other)

Copy assigns from other and returns a reference to this object.

QDomElement QDomAttr::ownerElement ( ) const

Returns the element node this attribute is attached to or a null node if this attribute is not attached to any element.

void QDomAttr::setValue ( const QString data)

Sets the attribute's value to data.

See also
bool QDomAttr::specified ( ) const

Returns true if the attribute has been set by the user with setValue(). Returns false if the value has not been specified or set.

See also
QString QDomAttr::value ( ) const

Returns the value of the attribute or an empty string if the attribute has not been specified.

See also
specified(), setValue()