Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Classes  ·  Annotées  ·  Hiérarchie  ·  Fonctions  ·  Structure  · 

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

  • QDomElement () 
  • QDomElement ( const QDomElement & x ) 
  • QDomElement& operator= ( const QDomElement & ) 
  • ~QDomElement () 
  • void setTagName ( const QString & name ) 
  • QString tagName () const
  • 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, double value ) 
  • void removeAttribute ( const QString & name ) 
  • QDomAttr attributeNode ( const QString & name ) 
  • QDomAttr setAttributeNode ( const QDomAttr & newAttr ) 
  • QDomAttr removeAttributeNode ( const QDomAttr & oldAttr ) 
  • bool hasAttribute ( const QString & name ) const
  • virtual QDomNodeList elementsByTagName ( const QString & tagname ) const
  • void normalize () 
  • virtual QDomNamedNodeMap attributes () const
  • virtual QDomNode::NodeType nodeType () const
  • virtual bool isElement () const
  • QString text () const

Detailed Description

The QDomElement class represents one element 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. You can set attributes with the setAttribute() and setAttributeNode() functions.

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


Member Function Documentation

QDomElement::QDomElement ()

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

QDomElement::QDomElement ( const QDomElement & x )

Copy constructor.

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

QDomElement::~QDomElement ()

Destructor.

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

Returns the attribute with the 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 the name name. If no such attribute exists a null object is returned.

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

QDomNamedNodeMap QDomElement::attributes () const [virtual]

Returns a QDomNamedNodeMap containing all attributes for this element.

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

Reimplemented from QDomNode.

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

Returns a QDomNodeList containing all descendant elements of this element with the name tagname. The order they are in the node list, is the order they are encountered in a preorder traversal of the element tree.

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

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

bool QDomElement::isElement () const [virtual]

Returns TRUE.

Reimplemented from QDomNode.

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

Returns ElementNode.

Reimplemented from QDomNode.

void QDomElement::normalize ()

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

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

Assignment operator.

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

void QDomElement::removeAttribute ( const QString & name )

Removes the attribute with the name name from this element.

See also setAttribute() and attribute().

QDomAttr QDomElement::removeAttributeNode ( const QDomAttr & oldAttr )

Removes the attribute oldAttr from the element 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 name newAttr exists in the element, the function returns this attribute; otherwise the function returns a null attribute.

See also attributeNode().

void QDomElement::setTagName ( const QString & name )

Sets the tag name of this element.

See also tagName().

QString QDomElement::tagName () const

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

  <img src="myimg.png">

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>

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

Comments are ignored by this function. 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-2005 Trolltech, all rights reserved.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le blog Digia au hasard

Logo

Créer des applications avec un style Metro avec Qt, exemples en QML et C++, un article de Digia Qt traduit par Thibaut Cuvelier

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 2.3
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web