![]() |
| ||
Classes - Annotated - Tree - Functions - Home - Structure |
The QDomNode class is the base class for all nodes of the DOM tree. More...
#include <qdom.h>
Inherited by QDomDocumentType, QDomDocument, QDomDocumentFragment, QDomCharacterData, QDomAttr, QDomElement, QDomNotation, QDomEntity, QDomEntityReference and QDomProcessingInstruction.
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.
This enum defines the type of the node:
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.
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().
Changing the attributes in the map will also change the attributes of this QDomNode.
Reimplemented in QDomElement.
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().
See also isNull().
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.
See also lastChild() and childNodes().
Example: xml/outliner/outlinetree.cpp.
See also attributes().
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().
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().
If this function returns TRUE, this does not imply that this object is a QDomAttribute; you can get the QDomAttribute with toAttribute().
See also toAttr().
Reimplemented in QDomAttr.
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.
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.
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.
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.
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.
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.
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().
Example: xml/outliner/outlinetree.cpp.
Reimplemented in QDomElement.
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.
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.
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.
Example: xml/outliner/outlinetree.cpp.
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.
See also QDomImplementation::hasFeature().
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.
See also firstChild() and childNodes().
Only nodes of type ElmentNode or AttributeNode can have namespaces. A namespace must be specified during creation time; it is not possible to add a namespace afterwards.
See also prefix(), namespaceURI(), QDomDocument::createElementNS() and QDomDocument::createAttributeNS().
If no such direct child exists, a null node is returned.
See also nodeName().
Only nodes of type ElmentNode or AttributeNode can have namespaces. A namespace URI must be specified during creation time; it cannot be changed afterwards.
See also prefix(), localName(), QDomDocument::createElementNS() and QDomDocument::createAttributeNS().
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().
Example: xml/outliner/outlinetree.cpp.
The meaning of the name depends on the subclass:
See also nodeValue().
Example: xml/outliner/outlinetree.cpp.
See also toAttr(), toCDATASection(), toDocumentFragment(), toDocument(), toDocumentType(), toElement(), toEntityReference(), toText(), toEntity(), toNotation(), toProcessingInstruction(), toCharacterData() and toComment().
Reimplemented in QDomDocumentType, QDomDocument, QDomDocumentFragment, QDomCharacterData, QDomAttr, QDomElement, QDomNotation, QDomEntity, QDomEntityReference and QDomProcessingInstruction.
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().
Example: xml/outliner/outlinetree.cpp.
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.
Only nodes of type ElmentNode or AttributeNode can have namespaces. A namespace prefix must be specified during creation time; if a node was created with a namespace prefix, you can change it with setPrefix() afterwards.
If you create an elment or attribute with QDomDocument::createElement() or QDomDocument::createAttribute(), the prefix will be null. If you use QDomDocument::createElementNS() or QDomDocument::createAttributeNS() instead, the prefix will not be null - even if the name does not have a prefix. In that case, this function returns an empty, but not null string.
See also setPrefix(), localName(), namespaceURI(), QDomDocument::createElementNS() and QDomDocument::createAttributeNS().
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().
Returns a new reference to oldChild on success or a null node on failure.
See also insertBefore(), insertAfter(), replaceChild() and appendChild().
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 oldChild is replaced by all of the children of the fragment.
Returns a new reference to oldChild on success or a null node an failure.
See also insertBefore(), insertAfter(), removeChild() and appendChild().
See also nodeValue().
Only nodes of type ElmentNode or AttributeNode can have namespaces. A namespace prefix must be specified during creation time; it is not possible to add a namespace prefix afterwards.
See also prefix(), localName(), namespaceURI(), QDomDocument::createElementNS() and QDomDocument::createAttributeNS().
See also isAttr().
See also isCDATASection().
See also isCharacterData().
See also isComment().
See also isDocument().
See also isDocumentFragment().
See also isDocumentType().
See also isElement().
Example: xml/outliner/outlinetree.cpp.
See also isEntity().
See also isEntityReference().
See also isNotation().
See also isProcessingInstruction().
See also isText().
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 Trolltech | Trademarks | Qt version main-beta1
|