The QDomNode class is the base class for all the nodes in a DOM tree.
.PP
Many functions in the DOM return a QDomNode.
.PP
You can find out the type of a node using isAttr(), isCDATASection(), isDocumentFragment(), isDocument(), isDocumentType(), isElement(), isEntityReference(), isText(), isEntity(), isNotation(), isProcessingInstruction(), isCharacterData() and isComment().
.PP
A QDomNode can be converted into one of its subclasses using toAttr(), toCDATASection(), toDocumentFragment(), toDocument(), toDocumentType(), toElement(), toEntityReference(), toText(), toEntity(), toNotation(), toProcessingInstruction(), toCharacterData() or toComment(). You can convert a node to a null node with clear().
.PP
Copies of the QDomNode class share their data using explicit sharing. This means that modifying one node will change all copies. This is especially useful in combination with functions which return a QDomNode, e.g. firstChild(). You can make an independent (deep) copy of the node with cloneNode().
.PP
Nodes are inserted with insertBefore(), insertAfter() or appendChild(). You can replace one node with another using replaceChild() and remove a node with removeChild().
.PP
To traverse nodes use firstChild() to get a node's first child (if any), and nextSibling() to traverse. QDomNode also provides lastChild(), previousSibling() and parentNode(). To find the first child node with a particular node name use namedItem().
.PP
To find out if a node has children use hasChildNodes() and to get a list of all of a node's children use childNodes().
.PP
The node's name and value (the meaning of which varies depending on its type) is returned by nodeName() and nodeValue() respectively. The node's type is returned by nodeType(). The node's value can be set with setNodeValue().
.PP
The document to which the node belongs is returned by ownerDocument().
.PP
Adjacent QDomText nodes can be merged into a single node with normalize().
.PP
QDomElement nodes have attributes which can be retrieved with attributes().
.PP
QDomElement and QDomAttr nodes can have namespaces which can be retrieved with namespaceURI(). Their local name is retrieved with localName(), and their prefix with prefix(). The prefix can be set with setPrefix().
.PP
You can write the XML representation of the node to a text stream with save().
.PP
The following example looks for the first element in an XML document and prints the names of all the elements that are its direct children.
.PP
.nf
.br
QDomDocument d;
.br
d.setContent( someXML );
.br
QDomNode n = d.firstChild();
.br
while ( !n.isNull() ) {
.br
if ( n.isElement() ) {
.br
QDomElement e = n.toElement();
.br
cout << "Element name: " << e.tagName() << endl;
.br
break;
.br
}
.br
n = n.nextSibling();
.br
}
.br
.fi
.PP
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.
.PP
See also XML.
.SS "Member Type Documentation"
.SH "QDomNode::NodeType"
This enum defines the type of the node:
.TP
\fCQDomNode::ElementNode\fR
.TP
\fCQDomNode::AttributeNode\fR
.TP
\fCQDomNode::TextNode\fR
.TP
\fCQDomNode::CDATASectionNode\fR
.TP
\fCQDomNode::EntityReferenceNode\fR
.TP
\fCQDomNode::EntityNode\fR
.TP
\fCQDomNode::ProcessingInstructionNode\fR
.TP
\fCQDomNode::CommentNode\fR
.TP
\fCQDomNode::DocumentNode\fR
.TP
\fCQDomNode::DocumentTypeNode\fR
.TP
\fCQDomNode::DocumentFragmentNode\fR
.TP
\fCQDomNode::NotationNode\fR
.TP
\fCQDomNode::BaseNode\fR - A QDomNode object, i.e. not a QDomNode subclass.
.TP
\fCQDomNode::CharacterDataNode\fR
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QDomNode::QDomNode ()"
Constructs a null node.
.SH "QDomNode::QDomNode ( const QDomNode & n )"
Constructs a copy of \fIn\fR.
.PP
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().
If \fInewChild\fR is the child of another node, it is reparented to this node. If \fInewChild\fR is a child of this node, then its position in the list of children is changed.
.PP
If \fInewChild\fR is a QDomDocumentFragment, then the children of the fragment are removed from the fragment and appended.
.PP
Returns a new reference to \fInewChild\fR.
.PP
See also insertBefore(), insertAfter(), replaceChild(), and removeChild().
Creates a deep (not shallow) copy of the QDomNode.
.PP
If \fIdeep\fR is TRUE, then the cloning is done recursively which means that all the node's children are deep copied too. If \fIdeep\fR is FALSE only the node itself is copied and the copy will have no child nodes.
Returns the first child of the node. If there is no child node, a null node is returned. Changing the returned node will also change the node in the document tree.
Inserts the node \fInewChild\fR after the child node \fIrefChild\fR. \fIrefChild\fR must be a direct child of this node. If \fIrefChild\fR is null then \fInewChild\fR is appended as this node's last child.
.PP
If \fInewChild\fR is the child of another node, it is reparented to this node. If \fInewChild\fR is a child of this node, then its position in the list of children is changed.
.PP
If \fInewChild\fR is a QDomDocumentFragment, then the children of the fragment are removed from the fragment and inserted after \fIrefChild\fR.
.PP
Returns a new reference to \fInewChild\fR on success or a null node on failure.
.PP
See also insertBefore(), replaceChild(), removeChild(), and appendChild().
Inserts the node \fInewChild\fR before the child node \fIrefChild\fR. \fIrefChild\fR must be a direct child of this node. If \fIrefChild\fR is null then \fInewChild\fR is inserted as the node's first child.
.PP
If \fInewChild\fR is the child of another node, it is reparented to this node. If \fInewChild\fR is a child of this node, then its position in the list of children is changed.
.PP
If \fInewChild\fR is a QDomDocumentFragment, then the children of the fragment are removed from the fragment and inserted before \fIrefChild\fR.
.PP
Returns a new reference to \fInewChild\fR on success or a null node on failure.
.PP
See also insertAfter(), replaceChild(), removeChild(), and appendChild().
Returns TRUE if the node is a document fragment; otherwise returns FALSE.
.PP
If this function returns TRUE, it does not imply that this object is a QDomDocumentFragment; you can get the QDomDocumentFragment with toDocumentFragment().
Returns TRUE if the node is an entity reference; otherwise returns FALSE.
.PP
If this function returns TRUE, it does not imply that this object is a QDomEntityReference; you can get the QDomEntityReference with toEntityReference().
Returns TRUE if the node is a processing instruction; otherwise returns FALSE.
.PP
If this function returns TRUE, it does not imply that this object is a QDomProcessingInstruction; you can get the QProcessingInstruction with toProcessingInstruction().
Returns TRUE if the DOM implementation implements the feature \fIfeature\fR and this feature is supported by this node in the version \fIversion\fR; otherwise returns FALSE.
Returns the last child of the node. If there is no child node, a null node is returned. Changing the returned node will also change the node in the document tree.
If the node uses namespaces, this function returns the local name of the node; otherwise it returns QString::null.
.PP
Only nodes of type ElementNode or AttributeNode can have namespaces. A namespace must have been specified at creation time; it is not possible to add a namespace afterwards.
.PP
See also prefix(), namespaceURI(), QDomDocument::createElementNS(), and QDomDocument::createAttributeNS().
.SH "QDomNode QDomNode::namedItem ( const QString & name ) const"
Returns the first direct child node for which nodeName() equals \fIname\fR.
.PP
If no such direct child exists, a null node is returned.
The meaning of the name depends on the subclass: <center>.nf
.TS
l - l. Name Meaning QDomAttr The name of the attribute QDomCDATASection The string "#cdata-section" QDomComment The string "#comment" QDomDocument The string "#document" QDomDocumentFragment The string "#document-fragment" QDomDocumentType The name of the document type QDomElement The tag name QDomEntity The name of the entity QDomEntityReference The name of the referenced entity QDomNotation The name of the notation QDomProcessingInstruction The target of the processing instruction QDomText
The meaning of the value depends on the subclass: <center>.nf
.TS
l - l. Name Meaning QDomAttr The attribute value QDomCDATASection The content of the CDATA section QDomComment The comment QDomProcessingInstruction The data of the processing intruction QDomText
.TE
.fi
</center>
.PP
All the other subclasses do not have a node value and will return QString::null.
.PP
See also setNodeValue() and nodeName().
.PP
Example: xml/outliner/outlinetree.cpp.
.SH "void QDomNode::normalize ()\fC [virtual]\fR"
Calling normalize() on an element converts all its children into a standard form. This means that adjacent QDomText objects will be merged into a single text object (QDomCDATASection nodes are not merged).
.SH "bool QDomNode::operator!= ( const QDomNode & n ) const"
Returns TRUE if \fIn\fR and this DOM node are not equal; otherwise returns FALSE.
.SH "QDomNode & QDomNode::operator= ( const QDomNode & n )"
Assigns a copy of \fIn\fR to this DOM node.
.PP
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().
.SH "bool QDomNode::operator== ( const QDomNode & n ) const"
Returns TRUE if \fIn\fR and this DOM node are equal; otherwise returns FALSE.
Returns the namespace prefix of the node or QString::null if the node has no namespace prefix.
.PP
Only nodes of type ElementNode or AttributeNode can have namespaces. A namespace prefix must be specified at creation time. If a node was created with a namespace prefix, you can change it later with setPrefix().
.PP
If you create an element or attribute with QDomDocument::createElement() or QDomDocument::createAttribute(), the prefix will be QString::null. If you use QDomDocument::createElementNS() or QDomDocument::createAttributeNS() instead, the prefix will not be QString::null; but it might be an empty string if the name does not have a prefix.
.PP
See also setPrefix(), localName(), namespaceURI(), QDomDocument::createElementNS(), and QDomDocument::createAttributeNS().
Replaces \fIoldChild\fR with \fInewChild\fR. \fIoldChild\fR must be a direct child of this node.
.PP
If \fInewChild\fR is the child of another node, it is reparented to this node. If \fInewChild\fR is a child of this node, then its position in the list of children is changed.
.PP
If \fInewChild\fR is a QDomDocumentFragment, then \fIoldChild\fR is replaced by all of the children of the fragment.
.PP
Returns a new reference to \fIoldChild\fR on success or a null node an failure.
.PP
See also insertBefore(), insertAfter(), removeChild(), and appendChild().
Writes the XML representation of the node and all its children to the stream \fIstr\fR. This function uses \fIindent\fR as the amount of space to indent the node.
.SH "void QDomNode::setNodeValue ( const QString & v )\fC [virtual]\fR"
Sets the node's value to \fIv\fR.
.PP
See also nodeValue().
.SH "void QDomNode::setPrefix ( const QString & pre )\fC [virtual]\fR"
If the node has a namespace prefix, this function changes the namespace prefix of the node to \fIpre\fR. Otherwise this function does nothing.
.PP
Only nodes of type ElementNode or AttributeNode can have namespaces. A namespace prefix must have be specified at creation time; it is not possible to add a namespace prefix afterwards.
.PP
See also prefix(), localName(), namespaceURI(), QDomDocument::createElementNS(), and QDomDocument::createAttributeNS().
.SH "QDomAttr QDomNode::toAttr ()"
Converts a QDomNode into a QDomAttr. If the node is not an attribute, the returned object will be null.