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  · 

QDomNode Class Reference
[ XML module ]


The QDomNode class is the base class for all nodes of the DOM tree. More...

#include <qdom.h>

Inherited by QDomAttr, QDomCharacterData, QDomDocument, QDomDocumentFragment, QDomDocumentType, QDomElement, QDomEntity, QDomEntityReference, QDomNotation and QDomProcessingInstruction.

List of all member functions.

Public Members

  • enum NodeType { BaseNode = 0, ElementNode = 1, AttributeNode = 2, TextNode = 3, CDATASectionNode = 4, EntityReferenceNode = 5, EntityNode = 6, ProcessingInstructionNode = 7, CommentNode = 8, DocumentNode = 9, DocumentTypeNode = 10, DocumentFragmentNode = 11, NotationNode = 12, CharacterDataNode = 13 }
  • QDomNode () 
  • QDomNode ( const QDomNode & ) 
  • QDomNode& operator= ( const QDomNode & ) 
  • bool operator== ( const QDomNode & ) const
  • bool operator!= ( const QDomNode & ) const
  • virtual ~QDomNode () 
  • virtual QString nodeName () const
  • virtual QString nodeValue () const
  • virtual void setNodeValue ( const QString & ) 
  • virtual QDomNode::NodeType nodeType () const
  • virtual QDomNode parentNode () const
  • virtual QDomNodeList childNodes () const
  • virtual QDomNode firstChild () const
  • virtual QDomNode lastChild () const
  • virtual QDomNode previousSibling () const
  • virtual QDomNode nextSibling () const
  • virtual QDomNamedNodeMap attributes () const
  • virtual QDomDocument ownerDocument () const
  • virtual QDomNode insertBefore ( const QDomNode & newChild, const QDomNode & refChild ) 
  • virtual QDomNode insertAfter ( const QDomNode & newChild, const QDomNode & refChild ) 
  • virtual QDomNode replaceChild ( const QDomNode & newChild, const QDomNode & oldChild ) 
  • virtual QDomNode removeChild ( const QDomNode & oldChild ) 
  • virtual QDomNode appendChild ( const QDomNode & newChild ) 
  • virtual QDomNode cloneNode ( bool deep = TRUE ) const
  • virtual bool isAttr () const
  • virtual bool isCDATASection () const
  • virtual bool isDocumentFragment () const
  • virtual bool isDocument () const
  • virtual bool isDocumentType () const
  • virtual bool isElement () const
  • virtual bool isEntityReference () const
  • virtual bool isText () const
  • virtual bool isEntity () const
  • virtual bool isNotation () const
  • virtual bool isProcessingInstruction () const
  • virtual bool isCharacterData () const
  • virtual bool isComment () const
  • QDomNode namedItem ( const QString & name ) const
  • bool isNull () const
  • void clear () 
  • QDomAttr toAttr () 
  • QDomCDATASection toCDATASection () 
  • QDomDocumentFragment toDocumentFragment () 
  • QDomDocument toDocument () 
  • QDomDocumentType toDocumentType () 
  • QDomElement toElement () 
  • QDomEntityReference toEntityReference () 
  • QDomText toText () 
  • QDomEntity toEntity () 
  • QDomNotation toNotation () 
  • QDomProcessingInstruction toProcessingInstruction () 
  • QDomCharacterData toCharacterData () 
  • QDomComment toComment () 
  • void save ( QTextStream &, int ) const

Protected Members

  • QDomNode ( QDOM_NodePrivate * ) (internal)

Detailed Description

The QDomNode class is the base class for all nodes of the DOM tree.

This class is the base class for almost all other classes in the DOM. Many functions in the DOM return a QDomNode. The various isXxx() functions are useful to find out the type of the node. A QDomNode can be converted to a subclass by using the toXxx() function family.

Copies of the QDomNode class share their data; this means modifying one will change all copies. This is especially useful in combination with functions which return a QDomNode, e.g. firstChild(). You can make an independent copy of the node with cloneNode().

The following example looks for the first element in an XML document and prints its name:

  QDomDocument d;
  d.setContent( someXML );
  QDomNode n = d.firstChild();
  while ( !n.isNull() ) {
      if ( n.isElement ) {
          QDomElement e = n.toElement();
          cout << "The name of the element is " << e.tagName() << endl;
          return;
      }
      n = n.nextSibling();
  }
  cout << "no element in the Document" << endl;

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

QDomNode::QDomNode ()

Constructs an empty node.

QDomNode::QDomNode ( const QDomNode & n )

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.

QDomNode::~QDomNode () [virtual]

Destructor.

QDomNode QDomNode::appendChild ( const QDomNode & newChild ) [virtual]

Appends newChild to the end of the children list.

If newChild is currently child of another parent, then it is reparented. If newChild is currently a child of this QDomNode, then its position in the list of children is changed.

Returns a new reference to newChild.

See also insertBefore(), insertAfter(), replaceChild() and removeChild().

QDomNamedNodeMap QDomNode::attributes () const [virtual]

Returns a map of all attributes. Attributes are only provided for QDomElement.

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

Reimplemented in QDomElement.

QDomNodeList QDomNode::childNodes () const [virtual]

Returns a list of all child nodes.

Most often you will call this function on a QDomElement object. If the XML document looks like this:

  <body>
   <h1>Heading</h1>
   <p>Hallo <b>you</b></p>
  </body>

Then the list of child nodes for the "body"-element will contain the node created by the <h1> tag and the node created by the <p> tag.

The nodes in the list are not copied; so changing the nodes in the list will also change the children of this node.

See also firstChild() and lastChild().

void QDomNode::clear ()

Dereferences the internal object. The node is then a null node.

See also isNull().

QDomNode QDomNode::cloneNode ( bool deep = TRUE ) const [virtual]

Creates a real copy of the QDomNode.

If deep is TRUE, then the cloning is done recursive. That means all children are copied, too. Otherwise the cloned node does not contain child nodes.

QDomNode QDomNode::firstChild () const [virtual]

Returns the first child of the node. If there is no child node, a null node is returned.

See also lastChild() and childNodes().

QDomNode QDomNode::insertAfter ( const QDomNode & newChild, const QDomNode & refChild ) [virtual]

Inserts the node newChild after the child node refChild. refChild has to be a direct child of this node. If refChild is null then newChild is appended as last child.

If newChild is currently child of another parent, then it is reparented. If newChild is currently a child of this QDomNode, then its position in the list of children is changed.

If newChild is a QDomDocumentFragment, then the children of the fragment are removed from the fragment and inserted after refChild.

Returns a new reference to newChild on success or an empty node on failure.

See also insertBefore(), replaceChild(), removeChild() and appendChild().

QDomNode QDomNode::insertBefore ( const QDomNode & newChild, const QDomNode & refChild ) [virtual]

Inserts the node newChild before the child node refChild. refChild has to be a direct child of this node. If refChild is null then newChild is inserted as first child.

If newChild is currently child of another parent, then it is reparented. If newChild is currently a child of this QDomNode, then its position in the list of children is changed.

If newChild is a QDomDocumentFragment, then the children of the fragment are removed from the fragment and inserted after refChild.

Returns a new reference to newChild on success or an empty node on failure.

See also insertAfter(), replaceChild(), removeChild() and appendChild().

bool QDomNode::isAttr () const [virtual]

Returns TRUE if the node is an attribute, otherwise FALSE.

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

See also toAttribute().

Reimplemented in QDomAttr.

bool QDomNode::isCDATASection () const [virtual]

Returns TRUE if the node is a CDATA section, otherwise FALSE.

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

See also toCDATASection().

Reimplemented in QDomCDATASection.

bool QDomNode::isCharacterData () const [virtual]

Returns TRUE if the node is a character data node, otherwise FALSE.

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

See also toCharacterData().

Reimplemented in QDomCharacterData.

bool QDomNode::isComment () const [virtual]

Returns TRUE if the node is a comment, otherwise FALSE.

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

See also toComment().

Reimplemented in QDomComment.

bool QDomNode::isDocument () const [virtual]

Returns TRUE if the node is a document, otherwise FALSE.

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

See also toDocument().

Reimplemented in QDomDocument.

bool QDomNode::isDocumentFragment () const [virtual]

Returns TRUE if the node is a document fragment, otherwise FALSE.

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

See also toDocumentFragment().

Reimplemented in QDomDocumentFragment.

bool QDomNode::isDocumentType () const [virtual]

Returns TRUE if the node is a document type, otherwise FALSE.

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

See also toDocumentType().

Reimplemented in QDomDocumentType.

bool QDomNode::isElement () const [virtual]

Returns TRUE if the node is an element, otherwise FALSE.

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

See also toElement().

Reimplemented in QDomElement.

bool QDomNode::isEntity () const [virtual]

Returns TRUE if the node is an entity, otherwise FALSE.

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

See also toEntity().

Reimplemented in QDomEntity.

bool QDomNode::isEntityReference () const [virtual]

Returns TRUE if the node is an entity reference, otherwise FALSE.

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

See also toEntityReference().

Reimplemented in QDomEntityReference.

bool QDomNode::isNotation () const [virtual]

Returns TRUE if the node is a notation, otherwise FALSE.

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

See also toNotation().

Reimplemented in QDomNotation.

bool QDomNode::isNull () const

Returns TRUE if this node does not reference any internal object, otherwise FALSE.

bool QDomNode::isProcessingInstruction () const [virtual]

Returns TRUE if the node is a processing instruction, otherwise FALSE.

If this function returns TRUE, this does not imply that this object is a QDomProcessingInstruction; you can get the QProcessingInstruction with toProcessingInstruction().

See also toProcessingInstruction().

Reimplemented in QDomProcessingInstruction.

bool QDomNode::isText () const [virtual]

Returns TRUE if the node is a text, otherwise FALSE.

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

See also toText().

Reimplemented in QDomText.

QDomNode QDomNode::lastChild () const [virtual]

Returns the last child of the node. If there is no child node then a null node is returned.

See also firstChild() and childNodes().

QDomNode QDomNode::namedItem ( const QString & name ) const

Returns the first child node for which nodeName() equals name.

If no such direct child exists, a null node is returned.

See also nodeName().

QDomNode QDomNode::nextSibling () const [virtual]

Returns the next sibling in the document tree. Changing the returned node will also change the node in the document tree.

If you have XML like this:

  <h1>Heading</h1>
  <p>The text...</p>
  <h2>Next heading</h2>

and this QDomNode represents the <p> tag, the nextSibling will return the node representing the <h2> tag.

See also previousSibling().

QString QDomNode::nodeName () const [virtual]

Returns the name of the node.

The meaning of the name depends on the subclass:

See also nodeValue().

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

Returns the type of the node.

See also toAttr(), toCDATASection(), toDocumentFragment(), toDocument(), toDocumentType(), toElement(), toEntityReference(), toText(), toEntity(), toNotation(), toProcessingInstruction(), toCharacterData() and toComment().

Reimplemented in QDomNotation, QDomProcessingInstruction, QDomText, QDomCDATASection, QDomComment, QDomDocument, QDomElement, QDomCharacterData, QDomEntityReference, QDomEntity, QDomDocumentFragment, QDomDocumentType and QDomAttr.

QString QDomNode::nodeValue () const [virtual]

Returns the value of the node.

The meaning of the value depends on the subclass:

All other subclasses not listed above do not have a node value. These classes will return a null string.

See also setNodeValue() and nodeName().

bool QDomNode::operator!= ( const QDomNode & n ) const

Returns TRUE if the two nodes are not equal, otherwise FALSE.

QDomNode& QDomNode::operator= ( const QDomNode & n )

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.

bool QDomNode::operator== ( const QDomNode & n ) const

Returns TRUE if the two nodes are equal, otherwise FALSE.

QDomDocument QDomNode::ownerDocument () const [virtual]

Returns the document to which this node belongs.

QDomNode QDomNode::parentNode () const [virtual]

Returns the parent node, If this node has no parent, then a null node is returned (i.e. a node for which isNull() returns TRUE).

QDomNode QDomNode::previousSibling () const [virtual]

Returns the previous sibling in the document tree. Changing the returned node will also change the node in the document tree.

If you have XML like this:

  <h1>Heading</h1>
  <p>The text...</p>
  <h2>Next heading</h2>

and this QDomNode represents the <p> tag, the previousSibling will return the node representing the <h1> tag.

See also nextSibling().

QDomNode QDomNode::removeChild ( const QDomNode & oldChild ) [virtual]

Removes oldChild from the list of children. oldChild has to be a direct child of this node.

Returns a new reference to oldChild on success or a null node on failure.

See also insertBefore(), insertAfter(), replaceChild() and appendChild().

QDomNode QDomNode::replaceChild ( const QDomNode & newChild, const QDomNode & oldChild ) [virtual]

Replaces oldChild with newChild. oldChild has to be a direct child of this node.

If newChild is currently child of another parent, then it is reparented. If newChild is currently a child of this QDomNode, then its position in the list of children is changed.

If newChild is a QDomDocumentFragment, then the children of the fragment are removed from the fragment and inserted after refChild.

Returns a new reference to oldChild on success or a null node an failure.

See also insertBefore(), insertAfter(), removeChild() and appendChild().

void QDomNode::save ( QTextStream & str, int indent ) const

Writes the XML representation of the node including all its children on the stream.

void QDomNode::setNodeValue ( const QString & v ) [virtual]

Sets the value of the node to v.

See also nodeValue().

QDomAttr QDomNode::toAttr ()

Converts a QDomNode into a QDomAttr. If the node is not an attribute, the returned object will be null.

See also isAttr().

QDomCDATASection QDomNode::toCDATASection ()

Converts a QDomNode into a QDomCDATASection. If the node is not a CDATA section, the returned object will be null.

See also isCDATASection().

QDomCharacterData QDomNode::toCharacterData ()

Converts a QDomNode into a QDomCharacterData. If the node is not a character data node the returned object will be null.

See also isCharacterData().

QDomComment QDomNode::toComment ()

Converts a QDomNode into a QDomComment. If the node is not a comment the returned object will be null.

See also isComment().

QDomDocument QDomNode::toDocument ()

Converts a QDomNode into a QDomDocument. If the node is not a document the returned object will be null.

See also isDocument().

QDomDocumentFragment QDomNode::toDocumentFragment ()

Converts a QDomNode into a QDomDocumentFragment. If the node is not a document fragment the returned object will be null.

See also isDocumentFragment().

QDomDocumentType QDomNode::toDocumentType ()

Converts a QDomNode into a QDomDocumentType. If the node is not a document type the returned object will be null.

See also isDocumentType().

QDomElement QDomNode::toElement ()

Converts a QDomNode into a QDomElement. If the node is not an element the returned object will be null.

See also isElement().

QDomEntity QDomNode::toEntity ()

Converts a QDomNode into a QDomEntity. If the node is not an entity the returned object will be null.

See also isEntity().

QDomEntityReference QDomNode::toEntityReference ()

Converts a QDomNode into a QDomEntityReference. If the node is not an entity reference, the returned object will be null.

See also isEntityReference().

QDomNotation QDomNode::toNotation ()

Converts a QDomNode into a QDomNotation. If the node is not a notation the returned object will be null.

See also isNotation().

QDomProcessingInstruction QDomNode::toProcessingInstruction ()

Converts a QDomNode into a QDomProcessingInstruction. If the node is not a processing instruction the returned object will be null.

See also isProcessingInstruction().

QDomText QDomNode::toText ()

Converts a QDomNode into a QDomText. If the node is not a text, the returned object will be null.

See also isText().

QDomNode::QDomNode ( QDOM_NodePrivate * n ) [protected]

For internal use only.


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 102
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 53
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 73
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 27
  5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
Page suivante
  1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
  2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 229
  3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
  4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
  5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
  6. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
  7. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 101
Page suivante

Le Qt Developer Network au hasard

Logo

Combiner licence, à propos et fermer d'une autre manière

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. 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