Eneboo - Documentación para desarrolladores
Métodos públicos | Amigas
Referencia de la Clase QDomElement

The QDomElement class represents one element in the DOM tree.XMLElements have a tagName() and zero or more attributes associated with them. The tag name can be changed with setTagName(). Más...

#include <qdom.h>

Diagrama de herencias de QDomElement
QDomNode QDomNode

Lista de todos los miembros.

Métodos públicos

 QDomElement ()
 QDomElement (const QDomElement &x)
QDomElementoperator= (const QDomElement &)
 ~QDomElement ()
QString attribute (const QString &name, const QString &defValue=QString::null) const
void setAttribute (const QString &name, const QString &value)
void setAttribute (const QString &name, int value)
void setAttribute (const QString &name, uint value)
void setAttribute (const QString &name, long value)
void setAttribute (const QString &name, ulong value)
void setAttribute (const QString &name, double value)
void removeAttribute (const QString &name)
QDomAttr attributeNode (const QString &name)
QDomAttr setAttributeNode (const QDomAttr &newAttr)
QDomAttr removeAttributeNode (const QDomAttr &oldAttr)
virtual QDomNodeList elementsByTagName (const QString &tagname) const
bool hasAttribute (const QString &name) const
QString attributeNS (const QString nsURI, const QString &localName, const QString &defValue) const
void setAttributeNS (const QString nsURI, const QString &qName, const QString &value)
void setAttributeNS (const QString nsURI, const QString &qName, int value)
void setAttributeNS (const QString nsURI, const QString &qName, uint value)
void setAttributeNS (const QString nsURI, const QString &qName, long value)
void setAttributeNS (const QString nsURI, const QString &qName, ulong value)
void setAttributeNS (const QString nsURI, const QString &qName, double value)
void removeAttributeNS (const QString &nsURI, const QString &localName)
QDomAttr attributeNodeNS (const QString &nsURI, const QString &localName)
QDomAttr setAttributeNodeNS (const QDomAttr &newAttr)
virtual QDomNodeList elementsByTagNameNS (const QString &nsURI, const QString &localName) const
bool hasAttributeNS (const QString &nsURI, const QString &localName) const
QString tagName () const
void setTagName (const QString &name)
QDomNamedNodeMap attributes () const
QDomNode::NodeType nodeType () const
bool isElement () const
QString text () const
 QDomElement ()
 QDomElement (const QDomElement &x)
QDomElementoperator= (const QDomElement &)
 ~QDomElement ()
QString attribute (const QString &name, const QString &defValue=QString::null) const
void setAttribute (const QString &name, const QString &value)
void setAttribute (const QString &name, int value)
void setAttribute (const QString &name, uint value)
void setAttribute (const QString &name, long value)
void setAttribute (const QString &name, ulong value)
void setAttribute (const QString &name, double value)
void removeAttribute (const QString &name)
QDomAttr attributeNode (const QString &name)
QDomAttr setAttributeNode (const QDomAttr &newAttr)
QDomAttr removeAttributeNode (const QDomAttr &oldAttr)
virtual QDomNodeList elementsByTagName (const QString &tagname) const
bool hasAttribute (const QString &name) const
QString attributeNS (const QString nsURI, const QString &localName, const QString &defValue) const
void setAttributeNS (const QString nsURI, const QString &qName, const QString &value)
void setAttributeNS (const QString nsURI, const QString &qName, int value)
void setAttributeNS (const QString nsURI, const QString &qName, uint value)
void setAttributeNS (const QString nsURI, const QString &qName, long value)
void setAttributeNS (const QString nsURI, const QString &qName, ulong value)
void setAttributeNS (const QString nsURI, const QString &qName, double value)
void removeAttributeNS (const QString &nsURI, const QString &localName)
QDomAttr attributeNodeNS (const QString &nsURI, const QString &localName)
QDomAttr setAttributeNodeNS (const QDomAttr &newAttr)
virtual QDomNodeList elementsByTagNameNS (const QString &nsURI, const QString &localName) const
bool hasAttributeNS (const QString &nsURI, const QString &localName) const
QString tagName () const
void setTagName (const QString &name)
QDomNamedNodeMap attributes () const
QDomNode::NodeType nodeType () const
bool isElement () const
QString text () const

Amigas

class QDomDocument
class QDomNode
class QDomAttr

Descripción detallada

The QDomElement class represents one element in the DOM tree.

XML

Elements have a tagName() and zero or more attributes associated with them. The tag name can be changed with setTagName().

Element attributes are represented by QDomAttr objects that can be queried using the attribute() and attributeNode() functions. You can set attributes with the setAttribute() and setAttributeNode() functions. Attributes can be removed with removeAttribute(). There are namespace-aware equivalents to these functions, i.e. setAttributeNS(), setAttributeNodeNS() and removeAttributeNS().

If you want to access the text of a node use text(), e.g.

    QDomElement e = //...
    //...
    QString s = e.text()

The text() function operates recursively to find the text (since not all elements contain text). If you want to find all the text in all of a node's children, iterate over the children looking for QDomText nodes, e.g.

    QString text;
    QDomElement element = doc.documentElement();
    for( QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() )
    {
        QDomText t = n.toText();
        if ( !t.isNull() )
            text += t.data();
    }

Note that we attempt to convert each node to a text node and use text() rather than using firstChild().toText().data() or n.toText().data() directly on the node, because the node may not be a text element.

You can get a list of all the decendents of an element which have a specified tag name with elementsByTagName() or elementsByTagNameNS().

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


Documentación del constructor y destructor

QDomElement::QDomElement ( )

Constructs an empty element. Use the QDomDocument::createElement() function to construct elements with content.

QDomElement::QDomElement ( const QDomElement x)

Constructs a copy of x.

The data of the copy is shared (shallow copy): modifying one node will also change the other. If you want to make a deep copy, use cloneNode().

QDomElement::~QDomElement ( )

Destroys the object and frees its resources.

QDomElement::QDomElement ( )
QDomElement::QDomElement ( const QDomElement x)
QDomElement::~QDomElement ( )

Documentación de las funciones miembro

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

Returns the attribute called name. If the attribute does not exist defValue is returned.

Ver también:
setAttribute() attributeNode() setAttributeNode() attributeNS()
QString QDomElement::attribute ( const QString name,
const QString defValue = QString::null 
) const
QDomAttr QDomElement::attributeNode ( const QString name)

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

Ver también:
setAttributeNode() attribute() setAttribute() attributeNodeNS()
QDomAttr QDomElement::attributeNode ( const QString name)
QDomAttr QDomElement::attributeNodeNS ( const QString nsURI,
const QString localName 
)

Returns the QDomAttr object that corresponds to the attribute with the local name localName and the namespace URI nsURI. If no such attribute exists a null attribute is returned.

Ver también:
setAttributeNode() attribute() setAttribute() attributeNodeNS()
QDomAttr QDomElement::attributeNodeNS ( const QString nsURI,
const QString localName 
)
QString QDomElement::attributeNS ( const QString  nsURI,
const QString localName,
const QString defValue 
) const
QString QDomElement::attributeNS ( const QString  nsURI,
const QString localName,
const QString defValue 
) const

Returns the attribute with the local name localName and the namespace URI nsURI. If the attribute does not exist defValue is returned.

Ver también:
setAttributeNS() attributeNodeNS() setAttributeNodeNS() attribute()
QDomNamedNodeMap QDomElement::attributes ( ) const [virtual]

Returns a QDomNamedNodeMap containing all this element's attributes.

Ver también:
attribute() setAttribute() attributeNode() setAttributeNode()

Reimplementado de QDomNode.

QDomNamedNodeMap QDomElement::attributes ( ) const [virtual]

Returns a named node map of all attributes. Attributes are only provided for {QDomElement}s.

Changing the attributes in the map will also change the attributes of this QDomNode.

Reimplementado de QDomNode.

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

Returns a QDomNodeList containing all descendent elements of this element that are called tagname. The order they are in the node list is the order they are encountered in a preorder traversal of the element tree.

Ver también:
elementsByTagNameNS() QDomDocument::elementsByTagName()
QDomNodeList QDomElement::elementsByTagNameNS ( const QString nsURI,
const QString localName 
) const [virtual]

Returns a QDomNodeList containing all the descendent elements of this element with the local name localName and the namespace URI nsURI. The order they are in the node list is the order they are encountered in a preorder traversal of the element tree.

Ver también:
elementsByTagName() QDomDocument::elementsByTagNameNS()
virtual QDomNodeList QDomElement::elementsByTagNameNS ( const QString nsURI,
const QString localName 
) const [virtual]
bool QDomElement::hasAttribute ( const QString name) const
bool QDomElement::hasAttribute ( const QString name) const

Returns TRUE if this element has an attribute called name; otherwise returns FALSE.

bool QDomElement::hasAttributeNS ( const QString nsURI,
const QString localName 
) const

Returns TRUE if this element has an attribute with the local name localName and the namespace URI nsURI; otherwise returns FALSE.

bool QDomElement::hasAttributeNS ( const QString nsURI,
const QString localName 
) const
bool QDomElement::isElement ( ) const [virtual]

Returns TRUE if the node is an element; otherwise returns FALSE.

If this function returns TRUE, it does not imply that this object is a QDomElement; you can get the QDomElement with toElement().

Ver también:
toElement()

Reimplementado de QDomNode.

bool QDomElement::isElement ( ) const [virtual]

Returns TRUE.

Reimplementado de QDomNode.

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

Returns ElementNode.

Reimplementado de QDomNode.

QDomNode::NodeType QDomElement::nodeType ( ) const [virtual]
QDomElement& QDomElement::operator= ( const QDomElement )
QDomElement & QDomElement::operator= ( const QDomElement x)

Assigns x to this DOM element.

The data of the copy is shared (shallow copy): modifying one node will also change the other. If you want to make a deep copy, use cloneNode().

void QDomElement::removeAttribute ( const QString name)

Removes the attribute called name name from this element.

Ver también:
setAttribute() attribute() removeAttributeNS()
void QDomElement::removeAttribute ( const QString name)
QDomAttr QDomElement::removeAttributeNode ( const QDomAttr oldAttr)
QDomAttr QDomElement::removeAttributeNode ( const QDomAttr oldAttr)

Removes the attribute oldAttr from the element and returns it.

Ver también:
attributeNode() setAttributeNode()
void QDomElement::removeAttributeNS ( const QString nsURI,
const QString localName 
)

Removes the attribute with the local name localName and the namespace URI nsURI from this element.

Ver también:
setAttributeNS() attributeNS() removeAttribute()
void QDomElement::removeAttributeNS ( const QString nsURI,
const QString localName 
)
void QDomElement::setAttribute ( const QString name,
uint  value 
)
void QDomElement::setAttribute ( const QString name,
double  value 
)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.

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

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.

void QDomElement::setAttribute ( const QString name,
int  value 
)
void QDomElement::setAttribute ( const QString name,
long  value 
)
void QDomElement::setAttribute ( const QString name,
ulong  value 
)
void QDomElement::setAttribute ( const QString name,
uint  value 
)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.

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

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.

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

Adds an attribute called name with value value. If an attribute with the same name exists, its value is replaced by value.

Ver también:
attribute() setAttributeNode() setAttributeNS()
void QDomElement::setAttribute ( const QString name,
ulong  value 
)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.

QDomAttr QDomElement::setAttributeNode ( const QDomAttr newAttr)
QDomAttr QDomElement::setAttributeNode ( const QDomAttr newAttr)

Adds the attribute newAttr to this element.

If the element has another attribute that has the same name as newAttr, this function replaces that attribute and returns it; otherwise the function returns a null attribute.

Ver también:
attributeNode() setAttribute() setAttributeNodeNS()
QDomAttr QDomElement::setAttributeNodeNS ( const QDomAttr newAttr)

Adds the attribute newAttr to this element.

If the element has another attribute that has the same local name and namespace URI as newAttr, this function replaces that attribute and returns it; otherwise the function returns a null attribute.

Ver también:
attributeNodeNS() setAttributeNS() setAttributeNode()
QDomAttr QDomElement::setAttributeNodeNS ( const QDomAttr newAttr)
void QDomElement::setAttributeNS ( const QString  nsURI,
const QString qName,
double  value 
)
void QDomElement::setAttributeNS ( const QString  nsURI,
const QString qName,
const QString value 
)

Adds an attribute with the qualified name qName and the namespace URI nsURI with the value value. If an attribute with the same local name and namespace URI exists, its prefix is replaced by the prefix of qName and its value is repaced by value.

Although qName is the qualified name, the local name is used to decide if an existing attribute's value should be replaced.

Ver también:
attributeNS() setAttributeNodeNS() setAttribute()
void QDomElement::setAttributeNS ( const QString  nsURI,
const QString qName,
double  value 
)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.

void QDomElement::setAttributeNS ( const QString  nsURI,
const QString qName,
int  value 
)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.

void QDomElement::setAttributeNS ( const QString  nsURI,
const QString qName,
const QString value 
)
void QDomElement::setAttributeNS ( const QString  nsURI,
const QString qName,
ulong  value 
)
void QDomElement::setAttributeNS ( const QString  nsURI,
const QString qName,
uint  value 
)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.

void QDomElement::setAttributeNS ( const QString  nsURI,
const QString qName,
int  value 
)
void QDomElement::setAttributeNS ( const QString  nsURI,
const QString qName,
ulong  value 
)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.

void QDomElement::setAttributeNS ( const QString  nsURI,
const QString qName,
long  value 
)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.

void QDomElement::setAttributeNS ( const QString  nsURI,
const QString qName,
long  value 
)
void QDomElement::setAttributeNS ( const QString  nsURI,
const QString qName,
uint  value 
)
void QDomElement::setTagName ( const QString name)

Sets this element's tag name to name.

Ver también:
tagName()
void QDomElement::setTagName ( const QString name)
QString QDomElement::tagName ( ) const

Returns the tag name of this element. For an XML element like this:

    <img src="myimg.png">

the tagname would return "img".

Ver también:
setTagName()
QString QDomElement::tagName ( ) const
QString QDomElement::text ( ) const
QString QDomElement::text ( ) const

Returns the element's text or QString::null.

Example:

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

The function text() of the QDomElement for the <h1> tag, will return "Hello Qt &lt;xml is cool&gt;".

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


Documentación de las funciones relacionadas y clases amigas

QDomAttr [friend]
QDomDocument [friend]

Reimplementado de QDomNode.

QDomNode [friend]

La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'