HomeHome

ClassesAnnotated - TreeFunctionsHomeStructure

QDomElement Class Reference
[ XML module ]


The QDomElement class represents one Element in the DOM tree. More...

#include <qdom.h>

Inherits QDomNode.

List of all member functions.

Public Members


Detailed Description

The QDomElement class represents one Element in the DOM tree.

The QDomElement class is a representation for XML elements in the DOM tree. Elements have a name() and zero or more attributes associated with them.

Attributes of the element are represented by QDomAttr objects, that can be queried using the attribute() and attributeNode() functions. Setting is done with the setAttribute() and setAttributeNode() methods.

For further information about the Document Objct Model see http://www.w3.org/TR/REC-DOM-Level-1/ . For a more general introduction into the internals of the DOM implementation see the QDomDocument documentation.


Member Function Documentation

QDomElement::QDomElement ()

Constructs a null Element. Use the QDomDocument::createElement() function to construct elements with contents.

QDomElement::QDomElement ( const QDomElement & x )

Copy constructor.

QDomElement::~QDomElement ()

Destructor.

QString QDomElement::attribute ( const QString & name, const QString & defValue = QString::null ) const

returns the attribute with name name. If the attribute does not exist defValue is returned.

See also: setAttribute(), attributeNode() and setAttributeNode().

QDomAttr QDomElement::attributeNode ( const QString & name )

Returns the QDomAttr object that corresponds to the attribute with name name. If no such attribute exists a null object is returned.

See also: setAttributeNode(), attribute() and setAttribute().

QDomNodeList QDomElement::elementsByTagName ( const QString & tagname ) const [virtual]

returns a QDomNodeList containing all child elements of this element with the tag name tagname.

bool QDomElement::hasAttribute ( const QString & name ) const

Returns TRUE is this element has an attribute with the name name.

bool QDomElement::isElement () const [virtual]

Returns true.

Reimplemented from QDomNode.

QDomNode::NodeType QDomElement::nodeType() const [virtual]

Returns QDomNode::ElementNode.

See also: QDomNode::nodeType().

Reimplemented from QDomNode.

void QDomElement::normalize ()

Calling normalize() on an element brings all its children into a standard form. This mainly means, that adjacent QDomText objects will be merged to one text object.

QDomElement& QDomElement::operator= ( const QDomElement & x )

assignment operator.

void QDomElement::removeAttribute ( const QString & name )

removes the attribute with name name from this element.

/sa setAttribute() attribute().

QDomAttr QDomElement::removeAttributeNode ( const QDomAttr & oldAttr )

removes the attribute oldAttr points to, and returns it.

See also: attributeNode() and setAttributeNode().

void QDomElement::setAttribute ( const QString & name, const QString & value )

sets the attribute with the name name to the string value. If the attribute does not exist, a new one is created.

void QDomElement::setAttribute ( const QString & name, double value )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void QDomElement::setAttribute ( const QString & name, int value )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void QDomElement::setAttribute ( const QString & name, uint value )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

QDomAttr QDomElement::setAttributeNode ( const QDomAttr & newAttr )

adds the attribute newAttr to this element. If an attribute with the same name as newAttr existed in the element it is returned, or otherwise a null attribute.

See also: attributeNode().

void QDomElement::setTagName ( const QString & name )

function to set the tag name of this element.

See also: tagName().

QString QDomElement::tagName () const

Returns the tag name of this element. For an XML element as

  <img src="myimg.pmg">

the tagname would return "img".

See also: setTagName().

QString QDomElement::text () const

Returns the text contained inside this element.

Example:

  <h1>Hello <b>Qt</b> <![CDATA[<xml is cool>]]></h1>

If this QDomElement represents the

tag, then text() will return "Hello Qt ".

Comments are ignored by this method. It evaluates only QDomText and QDomCDATASection objects.


Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):


This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.


Copyright İ 2000 TrolltechTrademarks
Qt version 2.2.0-beta2