Qt 4.8
|
The QDomNode class is the base class for all the nodes in a DOM tree. More...
#include <qdom.h>
Public Types | |
enum | EncodingPolicy { EncodingFromDocument = 1, EncodingFromTextStream = 2 } |
This enum specifies how QDomNode::save() determines what encoding to use when serializing. More... | |
enum | NodeType { ElementNode = 1, AttributeNode = 2, TextNode = 3, CDATASectionNode = 4, EntityReferenceNode = 5, EntityNode = 6, ProcessingInstructionNode = 7, CommentNode = 8, DocumentNode = 9, DocumentTypeNode = 10, DocumentFragmentNode = 11, NotationNode = 12, BaseNode = 21, CharacterDataNode = 22 } |
This enum defines the type of the node: More... | |
Public Functions | |
QDomNode | appendChild (const QDomNode &newChild) |
Appends newChild as the node's last child. More... | |
QDomNamedNodeMap | attributes () const |
Returns a named node map of all attributes. More... | |
QDomNodeList | childNodes () const |
Returns a list of all direct child nodes. More... | |
void | clear () |
Converts the node into a null node; if it was not a null node before, its type and contents are deleted. More... | |
QDomNode | cloneNode (bool deep=true) const |
Creates a deep (not shallow) copy of the QDomNode. More... | |
int | columnNumber () const |
For nodes created by QDomDocument::setContent(), this function returns the column number in the XML document where the node was parsed. More... | |
QDomNode | firstChild () const |
Returns the first child of the node. More... | |
QDomElement | firstChildElement (const QString &tagName=QString()) const |
Returns the first child element with tag name tagName if tagName is non-empty; otherwise returns the first child element. More... | |
bool | hasAttributes () const |
Returns true if the node has attributes; otherwise returns false. More... | |
bool | hasChildNodes () const |
Returns true if the node has one or more children; otherwise returns false. More... | |
QDomNode | insertAfter (const QDomNode &newChild, const QDomNode &refChild) |
Inserts the node newChild after the child node refChild. More... | |
QDomNode | insertBefore (const QDomNode &newChild, const QDomNode &refChild) |
Inserts the node newChild before the child node refChild. More... | |
bool | isAttr () const |
Returns true if the node is an attribute; otherwise returns false. More... | |
bool | isCDATASection () const |
Returns true if the node is a CDATA section; otherwise returns false. More... | |
bool | isCharacterData () const |
Returns true if the node is a character data node; otherwise returns false. More... | |
bool | isComment () const |
Returns true if the node is a comment; otherwise returns false. More... | |
bool | isDocument () const |
Returns true if the node is a document; otherwise returns false. More... | |
bool | isDocumentFragment () const |
Returns true if the node is a document fragment; otherwise returns false. More... | |
bool | isDocumentType () const |
Returns true if the node is a document type; otherwise returns false. More... | |
bool | isElement () const |
Returns true if the node is an element; otherwise returns false. More... | |
bool | isEntity () const |
Returns true if the node is an entity; otherwise returns false. More... | |
bool | isEntityReference () const |
Returns true if the node is an entity reference; otherwise returns false. More... | |
bool | isNotation () const |
Returns true if the node is a notation; otherwise returns false. More... | |
bool | isNull () const |
Returns true if this node is null (i.e. More... | |
bool | isProcessingInstruction () const |
Returns true if the node is a processing instruction; otherwise returns false. More... | |
bool | isSupported (const QString &feature, const QString &version) const |
Returns true if the DOM implementation implements the feature feature and this feature is supported by this node in the version version; otherwise returns false. More... | |
bool | isText () const |
Returns true if the node is a text node; otherwise returns false. More... | |
QDomNode | lastChild () const |
Returns the last child of the node. More... | |
QDomElement | lastChildElement (const QString &tagName=QString()) const |
Returns the last child element with tag name tagName if tagName is non-empty; otherwise returns the last child element. More... | |
int | lineNumber () const |
For nodes created by QDomDocument::setContent(), this function returns the line number in the XML document where the node was parsed. More... | |
QString | localName () const |
If the node uses namespaces, this function returns the local name of the node; otherwise it returns an empty string. More... | |
QDomNode | namedItem (const QString &name) const |
Returns the first direct child node for which nodeName() equals name. More... | |
QString | namespaceURI () const |
Returns the namespace URI of this node or an empty string if the node has no namespace URI. More... | |
QDomNode | nextSibling () const |
Returns the next sibling in the document tree. More... | |
QDomElement | nextSiblingElement (const QString &taName=QString()) const |
Returns the next sibling element with tag name tagName if tagName is non-empty; otherwise returns any next sibling element. More... | |
QString | nodeName () const |
Returns the name of the node. More... | |
NodeType | nodeType () const |
Returns the type of the node. More... | |
QString | nodeValue () const |
Returns the value of the node. More... | |
void | normalize () |
Calling normalize() on an element converts all its children into a standard form. More... | |
bool | operator!= (const QDomNode &) const |
Returns true if n and this DOM node are not equal; otherwise returns false. More... | |
QDomNode & | operator= (const QDomNode &) |
Assigns a copy of n to this DOM node. More... | |
bool | operator== (const QDomNode &) const |
Returns true if n and this DOM node are equal; otherwise returns false. More... | |
QDomDocument | ownerDocument () const |
Returns the document to which this node belongs. More... | |
QDomNode | parentNode () const |
Returns the parent node. More... | |
QString | prefix () const |
Returns the namespace prefix of the node or an empty string if the node has no namespace prefix. More... | |
QDomNode | previousSibling () const |
Returns the previous sibling in the document tree. More... | |
QDomElement | previousSiblingElement (const QString &tagName=QString()) const |
Returns the previous sibilng element with tag name tagName if tagName is non-empty; otherwise returns any previous sibling element. More... | |
QDomNode () | |
Constructs a null node. More... | |
QDomNode (const QDomNode &) | |
Constructs a copy of n. More... | |
QDomNode | removeChild (const QDomNode &oldChild) |
Removes oldChild from the list of children. More... | |
QDomNode | replaceChild (const QDomNode &newChild, const QDomNode &oldChild) |
Replaces oldChild with newChild. More... | |
void | save (QTextStream &, int) const |
Writes the XML representation of the node and all its children to the stream str. More... | |
void | save (QTextStream &, int, EncodingPolicy) const |
If encodingPolicy is QDomNode::EncodingFromDocument, this function behaves as save(QTextStream &str, int indent). More... | |
void | setNodeValue (const QString &) |
Sets the node's value to v. More... | |
void | setPrefix (const QString &pre) |
If the node has a namespace prefix, this function changes the namespace prefix of the node to pre. More... | |
QDomAttr | toAttr () const |
Converts a QDomNode into a QDomAttr. More... | |
QDomCDATASection | toCDATASection () const |
Converts a QDomNode into a QDomCDATASection. More... | |
QDomCharacterData | toCharacterData () const |
Converts a QDomNode into a QDomCharacterData. More... | |
QDomComment | toComment () const |
Converts a QDomNode into a QDomComment. More... | |
QDomDocument | toDocument () const |
Converts a QDomNode into a QDomDocument. More... | |
QDomDocumentFragment | toDocumentFragment () const |
Converts a QDomNode into a QDomDocumentFragment. More... | |
QDomDocumentType | toDocumentType () const |
Converts a QDomNode into a QDomDocumentType. More... | |
QDomElement | toElement () const |
Converts a QDomNode into a QDomElement. More... | |
QDomEntity | toEntity () const |
Converts a QDomNode into a QDomEntity. More... | |
QDomEntityReference | toEntityReference () const |
Converts a QDomNode into a QDomEntityReference. More... | |
QDomNotation | toNotation () const |
Converts a QDomNode into a QDomNotation. More... | |
QDomProcessingInstruction | toProcessingInstruction () const |
Converts a QDomNode into a QDomProcessingInstruction. More... | |
QDomText | toText () const |
Converts a QDomNode into a QDomText. More... | |
~QDomNode () | |
Destroys the object and frees its resources. More... | |
Protected Functions | |
QDomNode (QDomNodePrivate *) | |
Constructs a new node for the data n. More... | |
Protected Variables | |
QDomNodePrivate * | impl |
Friends | |
class | QDomDocument |
class | QDomDocumentType |
class | QDomNamedNodeMap |
class | QDomNodeList |
Related Functions | |
(Note that these are not member functions.) | |
QTextStream & | operator<< (QTextStream &str, const QDomNode &node) |
Writes the XML representation of the node node and all its children to the stream str. More... | |
The QDomNode class is the base class for all the nodes in a DOM tree.
Many functions in the DOM return a QDomNode.
You can find out the type of a node using isAttr(), isCDATASection(), isDocumentFragment(), isDocument(), isDocumentType(), isElement(), isEntityReference(), isText(), isEntity(), isNotation(), isProcessingInstruction(), isCharacterData() and isComment().
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().
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().
A QDomNode can be null, much like a null pointer. Creating a copy of a null node results in another null node. It is not possible to modify a null node, but it is possible to assign another, possibly non-null node to it. In this case, the copy of the null node will remain null. You can check if a QDomNode is null by calling isNull(). The empty constructor of a QDomNode (or any of the derived classes) creates a null node.
Nodes are inserted with insertBefore(), insertAfter() or appendChild(). You can replace one node with another using replaceChild() and remove a node with removeChild().
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().
To find out if a node has children use hasChildNodes() and to get a list of all of a node's children use childNodes().
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().
The document to which the node belongs is returned by ownerDocument().
Adjacent QDomText nodes can be merged into a single node with normalize().
QDomElement nodes have attributes which can be retrieved with attributes().
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().
You can write the XML representation of the node to a text stream with save().
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.
For further information about the Document Object Model see Level 1 and Level 2 Core. For a more general introduction of the DOM implementation see the QDomDocument documentation.
This enum specifies how QDomNode::save() determines what encoding to use when serializing.
See also the overload of the save() function that takes an EncodingPolicy.
Enumerator | |
---|---|
EncodingFromDocument | |
EncodingFromTextStream |
Definition at line 148 of file qdom.h.
enum QDomNode::NodeType |
This enum defines the type of the node:
e. not a QDomNode subclass.
Definition at line 131 of file qdom.h.
QDomNode::QDomNode | ( | ) |
Constructs a null node.
Definition at line 2057 of file qdom.cpp.
Referenced by QDomDocument::importNode().
QDomNode::QDomNode | ( | const QDomNode & | n | ) |
Constructs a copy of n.
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().
Definition at line 2069 of file qdom.cpp.
QDomNode::~QDomNode | ( | ) |
|
protected |
Appends newChild as the node's last child.
If newChild is the child of another node, it is reparented to this node. If newChild is a child of this node, 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 appended.
If newChild is a QDomElement and this node is a QDomDocument that already has an element node as a child, newChild is not added as a child and a null node is returned.
Returns a new reference to newChild on success or a null node on failure.
Calling this function on a null node(created, for example, with the default constructor) does nothing and returns a null node.
The DOM specification disallow inserting attribute nodes, but for historical reasons, QDom accepts them anyway.
Definition at line 2655 of file qdom.cpp.
Referenced by QDomImplementation::createDocument().
QDomNamedNodeMap QDomNode::attributes | ( | ) | const |
Returns a named node map of all attributes.
Attributes are only provided for QDomElement.
Changing the attributes in the map will also change the attributes of this QDomNode.
Definition at line 2370 of file qdom.cpp.
Referenced by QDomElement::setAttributeNS().
QDomNodeList QDomNode::childNodes | ( | ) | const |
Returns a list of all direct child nodes.
Most often you will call this function on a QDomElement object.
For example, if the XML document looks like this:
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.
Definition at line 2290 of file qdom.cpp.
void QDomNode::clear | ( | void | ) |
QDomNode QDomNode::cloneNode | ( | bool | deep = true | ) | const |
int QDomNode::columnNumber | ( | ) | const |
For nodes created by QDomDocument::setContent(), this function returns the column number in the XML document where the node was parsed.
Otherwise, -1 is returned.
Definition at line 3091 of file qdom.cpp.
QDomNode QDomNode::firstChild | ( | ) | const |
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.
Definition at line 2304 of file qdom.cpp.
Referenced by QDBusXmlParser::object(), and QDBusXmlParser::objectTree().
QDomElement QDomNode::firstChildElement | ( | const QString & | tagName = QString() | ) | const |
Returns the first child element with tag name tagName if tagName is non-empty; otherwise returns the first child element.
Returns a null element if no such child exists.
Definition at line 2990 of file qdom.cpp.
Referenced by QDBusXmlParser::QDBusXmlParser().
bool QDomNode::hasAttributes | ( | ) | const |
Returns true if the node has attributes; otherwise returns false.
Definition at line 2521 of file qdom.cpp.
bool QDomNode::hasChildNodes | ( | ) | const |
Inserts the node newChild after the child node refChild.
refChild must be a direct child of this node. If refChild is null then newChild is appended as this node's last child.
If newChild is the child of another node, it is reparented to this node. If newChild is a child of this node, 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 a null node on failure.
The DOM specification disallow inserting attribute nodes, but due to historical reasons QDom accept them nevertheless.
Definition at line 2579 of file qdom.cpp.
Inserts the node newChild before the child node refChild.
refChild must be a direct child of this node. If refChild is null then newChild is inserted as the node's first child.
If newChild is the child of another node, it is reparented to this node. If newChild is a child of this node, 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 before refChild.
Returns a new reference to newChild on success or a null node on failure.
The DOM specification disallow inserting attribute nodes, but due to historical reasons QDom accept them nevertheless.
Definition at line 2550 of file qdom.cpp.
bool QDomNode::isAttr | ( | ) | const |
bool QDomNode::isCDATASection | ( | ) | const |
Returns true if the node is a CDATA section; otherwise returns false.
If this function returns true, it does not imply that this object is a QDomCDATASection; you can get the QDomCDATASection with toCDATASection().
Definition at line 2798 of file qdom.cpp.
bool QDomNode::isCharacterData | ( | ) | const |
Returns true if the node is a character data node; otherwise returns false.
If this function returns true, it does not imply that this object is a QDomCharacterData; you can get the QDomCharacterData with toCharacterData().
Definition at line 2958 of file qdom.cpp.
bool QDomNode::isComment | ( | ) | const |
Returns true if the node is a comment; otherwise returns false.
If this function returns true, it does not imply that this object is a QDomComment; you can get the QDomComment with toComment().
Definition at line 2973 of file qdom.cpp.
bool QDomNode::isDocument | ( | ) | const |
Returns true if the node is a document; otherwise returns false.
If this function returns true, it does not imply that this object is a QDomDocument; you can get the QDomDocument with toDocument().
Definition at line 2830 of file qdom.cpp.
bool QDomNode::isDocumentFragment | ( | ) | const |
Returns true if the node is a document fragment; otherwise returns false.
If this function returns true, it does not imply that this object is a QDomDocumentFragment; you can get the QDomDocumentFragment with toDocumentFragment().
Definition at line 2815 of file qdom.cpp.
bool QDomNode::isDocumentType | ( | ) | const |
Returns true if the node is a document type; otherwise returns false.
If this function returns true, it does not imply that this object is a QDomDocumentType; you can get the QDomDocumentType with toDocumentType().
Definition at line 2847 of file qdom.cpp.
bool QDomNode::isElement | ( | ) | const |
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().
Definition at line 2862 of file qdom.cpp.
bool QDomNode::isEntity | ( | ) | const |
Returns true if the node is an entity; otherwise returns false.
If this function returns true, it does not imply that this object is a QDomEntity; you can get the QDomEntity with toEntity().
Definition at line 2909 of file qdom.cpp.
bool QDomNode::isEntityReference | ( | ) | const |
Returns true if the node is an entity reference; otherwise returns false.
If this function returns true, it does not imply that this object is a QDomEntityReference; you can get the QDomEntityReference with toEntityReference().
Definition at line 2879 of file qdom.cpp.
bool QDomNode::isNotation | ( | ) | const |
Returns true if the node is a notation; otherwise returns false.
If this function returns true, it does not imply that this object is a QDomNotation; you can get the QDomNotation with toNotation().
Definition at line 2924 of file qdom.cpp.
bool QDomNode::isNull | ( | ) | const |
Returns true if this node is null (i.e.
if it has no type or contents); otherwise returns false.
Definition at line 2679 of file qdom.cpp.
Referenced by QDomImplementation::createDocument(), firstChildElement(), QDBusXmlParser::interfaces(), lastChildElement(), nextSiblingElement(), QDBusXmlParser::object(), QDBusXmlParser::objectTree(), parseAnnotations(), parseArgs(), previousSiblingElement(), and removeChild().
bool QDomNode::isProcessingInstruction | ( | ) | const |
Returns true if the node is a processing instruction; otherwise returns false.
If this function returns true, it does not imply that this object is a QDomProcessingInstruction; you can get the QProcessingInstruction with toProcessingInstruction().
Definition at line 2941 of file qdom.cpp.
Returns true if the DOM implementation implements the feature feature and this feature is supported by this node in the version version; otherwise returns false.
Definition at line 2423 of file qdom.cpp.
bool QDomNode::isText | ( | ) | const |
QDomNode QDomNode::lastChild | ( | ) | const |
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.
Definition at line 2318 of file qdom.cpp.
QDomElement QDomNode::lastChildElement | ( | const QString & | tagName = QString() | ) | const |
Returns the last child element with tag name tagName if tagName is non-empty; otherwise returns the last child element.
Returns a null element if no such child exists.
Definition at line 3010 of file qdom.cpp.
int QDomNode::lineNumber | ( | ) | const |
For nodes created by QDomDocument::setContent(), this function returns the line number in the XML document where the node was parsed.
Otherwise, -1 is returned.
Definition at line 3074 of file qdom.cpp.
QString QDomNode::localName | ( | ) | const |
If the node uses namespaces, this function returns the local name of the node; otherwise it returns an empty string.
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.
Definition at line 2509 of file qdom.cpp.
Returns the first direct child node for which nodeName() equals name.
Shortcut to avoid dealing with QDomNodeList all the time.
If no such direct child exists, a null node is returned.
Definition at line 2706 of file qdom.cpp.
QString QDomNode::namespaceURI | ( | ) | const |
Returns the namespace URI of this node or an empty string if the node has no namespace URI.
Only nodes of type ElementNode or AttributeNode can have namespaces. A namespace URI must be specified at creation time and cannot be changed later.
Definition at line 2441 of file qdom.cpp.
QDomNode QDomNode::nextSibling | ( | ) | const |
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:
and this QDomNode represents the
tag, nextSibling() will return the node representing the
Definition at line 2354 of file qdom.cpp.
QDomElement QDomNode::nextSiblingElement | ( | const QString & | tagName = QString() | ) | const |
Returns the next sibling element with tag name tagName if tagName is non-empty; otherwise returns any next sibling element.
Returns a null element if no such sibling exists.
Definition at line 3030 of file qdom.cpp.
QString QDomNode::nodeName | ( | ) | const |
Returns the name of the node.
The meaning of the name depends on the subclass:
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 string "#text" |
Note: This function does not take the presence of namespaces into account when processing the names of element and attribute nodes. As a result, the returned name can contain any namespace prefix that may be present. To obtain the node name of an element or attribute, use localName(); to obtain the namespace prefix, use namespaceURI().
Definition at line 2178 of file qdom.cpp.
QDomNode::NodeType QDomNode::nodeType | ( | ) | const |
Returns the type of the node.
Definition at line 2256 of file qdom.cpp.
Referenced by QDomCharacterData::nodeType().
QString QDomNode::nodeValue | ( | ) | const |
Returns the value of the node.
The meaning of the value depends on the subclass:
Name | Meaning |
QDomAttr | The attribute value |
QDomCDATASection | The content of the CDATA section |
QDomComment | The comment |
QDomProcessingInstruction | The data of the processing instruction |
QDomText | The text |
All the other subclasses do not have a node value and will return an empty string.
Definition at line 2206 of file qdom.cpp.
void QDomNode::normalize | ( | ) |
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).
Definition at line 2409 of file qdom.cpp.
bool QDomNode::operator!= | ( | const QDomNode & | n | ) | const |
Assigns a copy of n to this DOM node.
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().
Definition at line 2096 of file qdom.cpp.
Referenced by QDomDocument::operator=(), QDomDocumentFragment::operator=(), QDomCharacterData::operator=(), QDomAttr::operator=(), QDomComment::operator=(), and QDomCDATASection::operator=().
bool QDomNode::operator== | ( | const QDomNode & | n | ) | const |
Returns true if n and this DOM node are equal; otherwise returns false.
Any instance of QDomNode acts as a reference to an underlying data structure in QDomDocument. The test for equality checks if the two references point to the same underlying node. For example:
The two nodes (QDomElement is a QDomNode subclass) both refer to the document's root element, and {element1
== element2} will return true. On the other hand:
Even though both nodes are empty elements carrying the same name, {element3
== element4} will return false because they refer to two different nodes in the underlying data structure.
Definition at line 2126 of file qdom.cpp.
QDomDocument QDomNode::ownerDocument | ( | ) | const |
QDomNode QDomNode::parentNode | ( | ) | const |
QString QDomNode::prefix | ( | ) | const |
Returns the namespace prefix of the node or an empty string if the node has no namespace prefix.
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().
If you create an element or attribute with QDomDocument::createElement() or QDomDocument::createAttribute(), the prefix will be an empty string. If you use QDomDocument::createElementNS() or QDomDocument::createAttributeNS() instead, the prefix will not be an empty string; but it might be an empty string if the name does not have a prefix.
Definition at line 2469 of file qdom.cpp.
QDomNode QDomNode::previousSibling | ( | ) | const |
Returns the previous sibling in the document tree.
Changing the returned node will also change the node in the document tree.
For example, if you have XML like this:
and this QDomNode represents the <p> tag, previousSibling() will return the node representing the <h1> tag.
Definition at line 2336 of file qdom.cpp.
QDomElement QDomNode::previousSiblingElement | ( | const QString & | tagName = QString() | ) | const |
Returns the previous sibilng element with tag name tagName if tagName is non-empty; otherwise returns any previous sibling element.
Returns a null element if no such sibling exists.
Definition at line 3050 of file qdom.cpp.
Removes oldChild from the list of children.
oldChild must be a direct child of this node.
Returns a new reference to oldChild on success or a null node on failure.
Definition at line 2618 of file qdom.cpp.
Replaces oldChild with newChild.
oldChild must be a direct child of this node.
If newChild is the child of another node, it is reparented to this node. If newChild is a child of this node, 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.
Definition at line 2602 of file qdom.cpp.
void QDomNode::save | ( | QTextStream & | str, |
int | indent | ||
) | const |
Writes the XML representation of the node and all its children to the stream str.
This function uses indent as the amount of space to indent the node.
If this node is a document node, the encoding of text stream str's encoding is set by treating a processing instruction by name "xml" as an XML declaration, if such a one exists, and otherwise defaults to UTF-8. XML declarations are not processing instructions, but this behavior exists for historical reasons. If this node is not a document node, the text stream's encoding is used.
If the document contains invalid XML characters or characters that cannot be encoded in the given encoding, the result and behavior is undefined.
Definition at line 2728 of file qdom.cpp.
Referenced by QDBusXmlParser::interfaces(), QDBusXmlParser::object(), QDBusXmlParser::objectTree(), operator<<(), and QDomDocument::toString().
void QDomNode::save | ( | QTextStream & | str, |
int | indent, | ||
EncodingPolicy | encodingPolicy | ||
) | const |
If encodingPolicy is QDomNode::EncodingFromDocument, this function behaves as save(QTextStream &str, int indent).
If encodingPolicy is EncodingFromTextStream and this node is a document node, this function behaves as save(QTextStream &str, int indent) with the exception that the encoding specified in the text stream str is used.
If the document contains invalid XML characters or characters that cannot be encoded in the given encoding, the result and behavior is undefined.
Definition at line 2745 of file qdom.cpp.
void QDomNode::setNodeValue | ( | const QString & | v | ) |
void QDomNode::setPrefix | ( | const QString & | pre | ) |
If the node has a namespace prefix, this function changes the namespace prefix of the node to pre.
Otherwise this function does nothing.
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.
Definition at line 2489 of file qdom.cpp.
QDomAttr QDomNode::toAttr | ( | ) | const |
QDomCDATASection QDomNode::toCDATASection | ( | ) | const |
Converts a QDomNode into a QDomCDATASection.
If the node is not a CDATA section, the returned object will be null.
Definition at line 7393 of file qdom.cpp.
QDomCharacterData QDomNode::toCharacterData | ( | ) | const |
Converts a QDomNode into a QDomCharacterData.
If the node is not a character data node the returned object will be null.
Definition at line 7532 of file qdom.cpp.
QDomComment QDomNode::toComment | ( | ) | const |
Converts a QDomNode into a QDomComment.
If the node is not a comment the returned object will be null.
Definition at line 7546 of file qdom.cpp.
QDomDocument QDomNode::toDocument | ( | ) | const |
Converts a QDomNode into a QDomDocument.
If the node is not a document the returned object will be null.
Definition at line 7421 of file qdom.cpp.
QDomDocumentFragment QDomNode::toDocumentFragment | ( | ) | const |
Converts a QDomNode into a QDomDocumentFragment.
If the node is not a document fragment the returned object will be null.
Definition at line 7407 of file qdom.cpp.
QDomDocumentType QDomNode::toDocumentType | ( | ) | const |
Converts a QDomNode into a QDomDocumentType.
If the node is not a document type the returned object will be null.
Definition at line 7435 of file qdom.cpp.
QDomElement QDomNode::toElement | ( | ) | const |
Converts a QDomNode into a QDomElement.
If the node is not an element the returned object will be null.
Definition at line 7449 of file qdom.cpp.
Referenced by firstChildElement(), QDBusXmlParser::interfaces(), lastChildElement(), nextSiblingElement(), QDBusXmlParser::object(), QDBusXmlParser::objectTree(), parseAnnotations(), parseArgs(), and previousSiblingElement().
QDomEntity QDomNode::toEntity | ( | ) | const |
Converts a QDomNode into a QDomEntity.
If the node is not an entity the returned object will be null.
Definition at line 7490 of file qdom.cpp.
QDomEntityReference QDomNode::toEntityReference | ( | ) | const |
Converts a QDomNode into a QDomEntityReference.
If the node is not an entity reference, the returned object will be null.
Definition at line 7463 of file qdom.cpp.
QDomNotation QDomNode::toNotation | ( | ) | const |
Converts a QDomNode into a QDomNotation.
If the node is not a notation the returned object will be null.
Definition at line 7504 of file qdom.cpp.
QDomProcessingInstruction QDomNode::toProcessingInstruction | ( | ) | const |
Converts a QDomNode into a QDomProcessingInstruction.
If the node is not a processing instruction the returned object will be null.
Definition at line 7518 of file qdom.cpp.
QDomText QDomNode::toText | ( | ) | const |
|
related |
Writes the XML representation of the node node and all its children to the stream str.
Definition at line 2765 of file qdom.cpp.
|
friend |
Definition at line 247 of file qdom.h.
Referenced by QDomDocument::nodeType().
|
friend |
Definition at line 248 of file qdom.h.
Referenced by QDomDocument::doctype(), QDomDocumentType::nodeType(), and toDocumentType().
|
friend |
|
friend |
Definition at line 249 of file qdom.h.
Referenced by QDomDocument::elementsByTagName(), and QDomDocument::elementsByTagNameNS().
|
protected |
Definition at line 243 of file qdom.h.
Referenced by appendChild(), QDomCharacterData::appendData(), QDomDocument::createAttribute(), QDomDocument::createAttributeNS(), QDomDocument::createCDATASection(), QDomDocument::createComment(), QDomDocument::createDocumentFragment(), QDomDocument::createElement(), QDomDocument::createElementNS(), QDomDocument::createEntityReference(), QDomDocument::createProcessingInstruction(), QDomDocument::createTextNode(), QDomCharacterData::data(), QDomCharacterData::deleteData(), QDomDocument::doctype(), QDomDocument::documentElement(), QDomDocument::elementsByTagName(), QDomDocument::elementsByTagNameNS(), QDomDocument::implementation(), QDomDocument::importNode(), insertAfter(), insertBefore(), QDomCharacterData::insertData(), QDomCharacterData::length(), QDomAttr::name(), QDomCharacterData::nodeType(), operator!=(), operator=(), operator==(), QDomAttr::ownerElement(), QDomDocument::QDomDocument(), QDomNode(), removeChild(), replaceChild(), QDomCharacterData::replaceData(), QDomDocument::setContent(), QDomCharacterData::setData(), QDomNamedNodeMap::setNamedItem(), QDomNamedNodeMap::setNamedItemNS(), QDomAttr::setValue(), QDomAttr::specified(), QDomCharacterData::substringData(), toAttr(), toCDATASection(), toCharacterData(), toComment(), toDocument(), toDocumentFragment(), toDocumentType(), toElement(), toEntity(), toEntityReference(), toNotation(), toProcessingInstruction(), toText(), and QDomAttr::value().