Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QDomNode Class

TheQDomNode class is the base class for all the nodes in a DOM tree.More...

Note: All functions in this class arereentrant.

Public Types

enumEncodingPolicy { EncodingFromDocument, EncodingFromTextStream }
enumNodeType { ElementNode, AttributeNode, TextNode, CDATASectionNode, ..., CharacterDataNode }

Public Functions

QDomNode()
QDomNode(const QDomNode & n)
~QDomNode()
QDomNodeappendChild(const QDomNode & newChild)
QDomNamedNodeMapattributes() const
QDomNodeListchildNodes() const
voidclear()
QDomNodecloneNode(bool deep = true) const
intcolumnNumber() const
QDomNodefirstChild() const
QDomElementfirstChildElement(const QString & tagName = QString()) const
boolhasAttributes() const
boolhasChildNodes() const
QDomNodeinsertAfter(const QDomNode & newChild, const QDomNode & refChild)
QDomNodeinsertBefore(const QDomNode & newChild, const QDomNode & refChild)
boolisAttr() const
boolisCDATASection() const
boolisCharacterData() const
boolisComment() const
boolisDocument() const
boolisDocumentFragment() const
boolisDocumentType() const
boolisElement() const
boolisEntity() const
boolisEntityReference() const
boolisNotation() const
boolisNull() const
boolisProcessingInstruction() const
boolisSupported(const QString & feature, const QString & version) const
boolisText() const
QDomNodelastChild() const
QDomElementlastChildElement(const QString & tagName = QString()) const
intlineNumber() const
QStringlocalName() const
QDomNodenamedItem(const QString & name) const
QStringnamespaceURI() const
QDomNodenextSibling() const
QDomElementnextSiblingElement(const QString & tagName = QString()) const
QStringnodeName() const
NodeTypenodeType() const
QStringnodeValue() const
voidnormalize()
QDomDocumentownerDocument() const
QDomNodeparentNode() const
QStringprefix() const
QDomNodepreviousSibling() const
QDomElementpreviousSiblingElement(const QString & tagName = QString()) const
QDomNoderemoveChild(const QDomNode & oldChild)
QDomNodereplaceChild(const QDomNode & newChild, const QDomNode & oldChild)
voidsave(QTextStream & str, int indent) const
voidsave(QTextStream & str, int indent, EncodingPolicy encodingPolicy) const
voidsetNodeValue(const QString & v)
voidsetPrefix(const QString & pre)
QDomAttrtoAttr() const
QDomCDATASectiontoCDATASection() const
QDomCharacterDatatoCharacterData() const
QDomCommenttoComment() const
QDomDocumenttoDocument() const
QDomDocumentFragmenttoDocumentFragment() const
QDomDocumentTypetoDocumentType() const
QDomElementtoElement() const
QDomEntitytoEntity() const
QDomEntityReferencetoEntityReference() const
QDomNotationtoNotation() const
QDomProcessingInstructiontoProcessingInstruction() const
QDomTexttoText() const
booloperator!=(const QDomNode & n) const
QDomNode &operator=(const QDomNode & n)
booloperator==(const QDomNode & n) const

Related Non-Members

QTextStream &operator<<(QTextStream & str, const QDomNode & node)

Detailed Description

TheQDomNode class is the base class for all the nodes in a DOM tree.

Many functions in the DOM return aQDomNode.

You can find out the type of a node usingisAttr(),isCDATASection(),isDocumentFragment(),isDocument(),isDocumentType(),isElement(),isEntityReference(),isText(),isEntity(),isNotation(),isProcessingInstruction(),isCharacterData() andisComment().

AQDomNode can be converted into one of its subclasses usingtoAttr(),toCDATASection(),toDocumentFragment(),toDocument(),toDocumentType(),toElement(),toEntityReference(),toText(),toEntity(),toNotation(),toProcessingInstruction(),toCharacterData() ortoComment(). You can convert a node to a null node withclear().

Copies of theQDomNode 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 aQDomNode, e.g.firstChild(). You can make an independent (deep) copy of the node withcloneNode().

AQDomNode 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 aQDomNode is null by callingisNull(). The empty constructor of aQDomNode (or any of the derived classes) creates a null node.

Nodes are inserted withinsertBefore(),insertAfter() orappendChild(). You can replace one node with another usingreplaceChild() and remove a node withremoveChild().

To traverse nodes usefirstChild() to get a node's first child (if any), andnextSibling() to traverse.QDomNode also provideslastChild(),previousSibling() andparentNode(). To find the first child node with a particular node name usenamedItem().

To find out if a node has children usehasChildNodes() and to get a list of all of a node's children usechildNodes().

The node's name and value (the meaning of which varies depending on its type) is returned bynodeName() andnodeValue() respectively. The node's type is returned bynodeType(). The node's value can be set withsetNodeValue().

The document to which the node belongs is returned byownerDocument().

AdjacentQDomText nodes can be merged into a single node withnormalize().

QDomElement nodes have attributes which can be retrieved withattributes().

QDomElement andQDomAttr nodes can have namespaces which can be retrieved withnamespaceURI(). Their local name is retrieved withlocalName(), and their prefix withprefix(). The prefix can be set withsetPrefix().

You can write the XML representation of the node to a text stream withsave().

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.

QDomDocument d;d.setContent(someXML);QDomNode n= d.firstChild();while (!n.isNull()) {if (n.isElement()) {QDomElement e= n.toElement();        cout<<"Element name: "<< e.tagName()<< endl;break;    }    n= n.nextSibling();}

For further information about the Document Object Model seeLevel 1 andLevel 2 Core. For a more general introduction of the DOM implementation see theQDomDocument documentation.

Member Type Documentation

enum QDomNode::EncodingPolicy

This enum specifies howQDomNode::save() determines what encoding to use when serializing.

ConstantValueDescription
QDomNode::EncodingFromDocument1The encoding is fetched from the document.
QDomNode::EncodingFromTextStream2The encoding is fetched from theQTextStream.

See also the overload of thesave() function that takes an EncodingPolicy.

This enum was introduced or modified in Qt 4.3.

enum QDomNode::NodeType

This enum defines the type of the node:

ConstantValueDescription
QDomNode::ElementNode1 
QDomNode::AttributeNode2 
QDomNode::TextNode3 
QDomNode::CDATASectionNode4 
QDomNode::EntityReferenceNode5 
QDomNode::EntityNode6 
QDomNode::ProcessingInstructionNode7 
QDomNode::CommentNode8 
QDomNode::DocumentNode9 
QDomNode::DocumentTypeNode10 
QDomNode::DocumentFragmentNode11 
QDomNode::NotationNode12 
QDomNode::BaseNode21AQDomNode object, i.e. not aQDomNode subclass.
QDomNode::CharacterDataNode22 

Member Function Documentation

QDomNode::QDomNode()

Constructs anull node.

QDomNode::QDomNode(constQDomNode & n)

Constructs a copy ofn.

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, usecloneNode().

QDomNode::~QDomNode()

Destroys the object and frees its resources.

QDomNode QDomNode::appendChild(constQDomNode & newChild)

AppendsnewChild as the node's last child.

IfnewChild is the child of another node, it is reparented to this node. IfnewChild is a child of this node, then its position in the list of children is changed.

IfnewChild is aQDomDocumentFragment, then the children of the fragment are removed from the fragment and appended.

IfnewChild is aQDomElement and this node is aQDomDocument 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 tonewChild on success or anull node on failure.

Calling this function on a null node(created, for example, with the default constructor) does nothing and returns anull node.

The DOM specification disallow inserting attribute nodes, but for historical reasons, QDom accepts them anyway.

See alsoinsertBefore(),insertAfter(),replaceChild(), andremoveChild().

QDomNamedNodeMap QDomNode::attributes() const

Returns a named node map of all attributes. Attributes are only provided forQDomElements.

Changing the attributes in the map will also change the attributes of thisQDomNode.

QDomNodeList QDomNode::childNodes() const

Returns a list of all direct child nodes.

Most often you will call this function on aQDomElement object.

For example, if the XML document looks like this:

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

Then the list of child nodes for the "body"-element will contain the node created by the &lt;h1&gt; tag and the node created by the &lt;p&gt; 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 alsofirstChild() andlastChild().

void QDomNode::clear()

Converts the node into a null node; if it was not a null node before, its type and contents are deleted.

See alsoisNull().

QDomNode QDomNode::cloneNode(bool deep = true) const

Creates a deep (not shallow) copy of theQDomNode.

Ifdeep is true, then the cloning is done recursively which means that all the node's children are deep copied too. Ifdeep is false only the node itself is copied and the copy will have no child nodes.

int QDomNode::columnNumber() const

For nodes created byQDomDocument::setContent(), this function returns the column number in the XML document where the node was parsed. Otherwise, -1 is returned.

This function was introduced in Qt 4.1.

See alsolineNumber() andQDomDocument::setContent().

QDomNode QDomNode::firstChild() const

Returns the first child of the node. If there is no child node, anull node is returned. Changing the returned node will also change the node in the document tree.

See alsolastChild() andchildNodes().

QDomElement QDomNode::firstChildElement(constQString & tagName = QString()) const

Returns the first child element with tag nametagName if tagName is non-empty; otherwise returns the first child element. Returns a null element if no such child exists.

See alsolastChildElement(),previousSiblingElement(), andnextSiblingElement().

bool QDomNode::hasAttributes() const

Returns true if the node has attributes; otherwise returns false.

See alsoattributes().

bool QDomNode::hasChildNodes() const

Returns true if the node has one or more children; otherwise returns false.

QDomNode QDomNode::insertAfter(constQDomNode & newChild, constQDomNode & refChild)

Inserts the nodenewChild after the child noderefChild.refChild must be a direct child of this node. IfrefChild isnull thennewChild is appended as this node's last child.

IfnewChild is the child of another node, it is reparented to this node. IfnewChild is a child of this node, then its position in the list of children is changed.

IfnewChild is aQDomDocumentFragment, then the children of the fragment are removed from the fragment and inserted afterrefChild.

Returns a new reference tonewChild on success or anull node on failure.

The DOM specification disallow inserting attribute nodes, but due to historical reasons QDom accept them nevertheless.

See alsoinsertBefore(),replaceChild(),removeChild(), andappendChild().

QDomNode QDomNode::insertBefore(constQDomNode & newChild, constQDomNode & refChild)

Inserts the nodenewChild before the child noderefChild.refChild must be a direct child of this node. IfrefChild isnull thennewChild is inserted as the node's first child.

IfnewChild is the child of another node, it is reparented to this node. IfnewChild is a child of this node, then its position in the list of children is changed.

IfnewChild is aQDomDocumentFragment, then the children of the fragment are removed from the fragment and inserted beforerefChild.

Returns a new reference tonewChild on success or anull node on failure.

The DOM specification disallow inserting attribute nodes, but due to historical reasons QDom accept them nevertheless.

See alsoinsertAfter(),replaceChild(),removeChild(), andappendChild().

bool QDomNode::isAttr() const

Returns true if the node is an attribute; otherwise returns false.

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

See alsotoAttr().

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 aQDomCDATASection; you can get theQDomCDATASection withtoCDATASection().

See alsotoCDATASection().

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 aQDomCharacterData; you can get theQDomCharacterData withtoCharacterData().

See alsotoCharacterData().

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 aQDomComment; you can get theQDomComment withtoComment().

See alsotoComment().

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 aQDomDocument; you can get theQDomDocument withtoDocument().

See alsotoDocument().

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 aQDomDocumentFragment; you can get theQDomDocumentFragment withtoDocumentFragment().

See alsotoDocumentFragment().

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 aQDomDocumentType; you can get theQDomDocumentType withtoDocumentType().

See alsotoDocumentType().

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 aQDomElement; you can get theQDomElement withtoElement().

See alsotoElement().

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 aQDomEntity; you can get theQDomEntity withtoEntity().

See alsotoEntity().

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 aQDomEntityReference; you can get theQDomEntityReference withtoEntityReference().

See alsotoEntityReference().

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 aQDomNotation; you can get theQDomNotation withtoNotation().

See alsotoNotation().

bool QDomNode::isNull() const

Returns true if this node is null (i.e. if it has no type or contents); otherwise returns false.

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 aQDomProcessingInstruction; you can get the QProcessingInstruction withtoProcessingInstruction().

See alsotoProcessingInstruction().

bool QDomNode::isSupported(constQString & feature, constQString & version) const

Returns true if the DOM implementation implements the featurefeature and this feature is supported by this node in the versionversion; otherwise returns false.

See alsoQDomImplementation::hasFeature().

bool QDomNode::isText() const

Returns true if the node is a text node; otherwise returns false.

If this function returns true, it does not imply that this object is aQDomText; you can get theQDomText withtoText().

See alsotoText().

QDomNode QDomNode::lastChild() const

Returns the last child of the node. If there is no child node, anull node is returned. Changing the returned node will also change the node in the document tree.

See alsofirstChild() andchildNodes().

QDomElement QDomNode::lastChildElement(constQString & tagName = QString()) const

Returns the last child element with tag nametagName if tagName is non-empty; otherwise returns the last child element. Returns a null element if no such child exists.

See alsofirstChildElement(),previousSiblingElement(), andnextSiblingElement().

int QDomNode::lineNumber() const

For nodes created byQDomDocument::setContent(), this function returns the line number in the XML document where the node was parsed. Otherwise, -1 is returned.

This function was introduced in Qt 4.1.

See alsocolumnNumber() andQDomDocument::setContent().

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 typeElementNode orAttributeNode can have namespaces. A namespace must have been specified at creation time; it is not possible to add a namespace afterwards.

QDomDocument::createAttributeNS()

See alsoprefix(),namespaceURI(), andQDomDocument::createElementNS().

QDomNode QDomNode::namedItem(constQString & name) const

Returns the first direct child node for whichnodeName() equalsname.

If no such direct child exists, anull node is returned.

See alsonodeName().

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 typeElementNode orAttributeNode can have namespaces. A namespace URI must be specified at creation time and cannot be changed later.

QDomDocument::createAttributeNS()

See alsoprefix(),localName(), andQDomDocument::createElementNS().

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:

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

and thisQDomNode represents the <p> tag, nextSibling() will return the node representing the <h2> tag.

See alsopreviousSibling().

QDomElement QDomNode::nextSiblingElement(constQString & tagName = QString()) const

Returns the next sibling element with tag nametagName iftagName is non-empty; otherwise returns any next sibling element. Returns a null element if no such sibling exists.

See alsofirstChildElement(),previousSiblingElement(), andlastChildElement().

QString QDomNode::nodeName() const

Returns the name of the node.

The meaning of the name depends on the subclass:

NameMeaning
QDomAttrThe name of the attribute
QDomCDATASectionThe string "#cdata-section"
QDomCommentThe string "#comment"
QDomDocumentThe string "#document"
QDomDocumentFragmentThe string "#document-fragment"
QDomDocumentTypeThe name of the document type
QDomElementThe tag name
QDomEntityThe name of the entity
QDomEntityReferenceThe name of the referenced entity
QDomNotationThe name of the notation
QDomProcessingInstructionThe target of the processing instruction
QDomTextThe 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, uselocalName(); to obtain the namespace prefix, usenamespaceURI().

See alsonodeValue().

NodeType QDomNode::nodeType() const

Returns the type of the node.

See alsotoAttr(),toCDATASection(),toDocumentFragment(),toDocument(),toDocumentType(),toElement(),toEntityReference(),toText(),toEntity(),toNotation(),toProcessingInstruction(),toCharacterData(), andtoComment().

QString QDomNode::nodeValue() const

Returns the value of the node.

The meaning of the value depends on the subclass:

NameMeaning
QDomAttrThe attribute value
QDomCDATASectionThe content of the CDATA section
QDomCommentThe comment
QDomProcessingInstructionThe data of the processing instruction
QDomTextThe text

All the other subclasses do not have a node value and will return an empty string.

See alsosetNodeValue() andnodeName().

void QDomNode::normalize()

Calling normalize() on an element converts all its children into a standard form. This means that adjacentQDomText objects will be merged into a single text object (QDomCDATASection nodes are not merged).

QDomDocument QDomNode::ownerDocument() const

Returns the document to which this node belongs.

QDomNode QDomNode::parentNode() const

Returns the parent node. If this node has no parent, a null node is returned (i.e. a node for whichisNull() returns true).

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 typeElementNode orAttributeNode 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 withsetPrefix().

If you create an element or attribute withQDomDocument::createElement() orQDomDocument::createAttribute(), the prefix will be an empty string. If you useQDomDocument::createElementNS() orQDomDocument::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.

QDomDocument::createElementNS()QDomDocument::createAttributeNS()

See alsosetPrefix(),localName(), andnamespaceURI().

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:

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

and thisQDomNode represents the &lt;p&gt; tag, previousSibling() will return the node representing the &lt;h1&gt; tag.

See alsonextSibling().

QDomElement QDomNode::previousSiblingElement(constQString & tagName = QString()) const

Returns the previous sibilng element with tag nametagName iftagName is non-empty; otherwise returns any previous sibling element. Returns a null element if no such sibling exists.

See alsofirstChildElement(),nextSiblingElement(), andlastChildElement().

QDomNode QDomNode::removeChild(constQDomNode & oldChild)

RemovesoldChild from the list of children.oldChild must be a direct child of this node.

Returns a new reference tooldChild on success or anull node on failure.

See alsoinsertBefore(),insertAfter(),replaceChild(), andappendChild().

QDomNode QDomNode::replaceChild(constQDomNode & newChild, constQDomNode & oldChild)

ReplacesoldChild withnewChild.oldChild must be a direct child of this node.

IfnewChild is the child of another node, it is reparented to this node. IfnewChild is a child of this node, then its position in the list of children is changed.

IfnewChild is aQDomDocumentFragment, thenoldChild is replaced by all of the children of the fragment.

Returns a new reference tooldChild on success or anull node an failure.

See alsoinsertBefore(),insertAfter(),removeChild(), andappendChild().

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

Writes the XML representation of the node and all its children to the streamstr. This function usesindent as the amount of space to indent the node.

If this node is a document node, the encoding of text streamstr'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.

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

IfencodingPolicy isQDomNode::EncodingFromDocument, this function behaves as save(QTextStream &str, int indent).

IfencodingPolicy isEncodingFromTextStream 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 streamstr 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.

This function was introduced in Qt 4.2.

void QDomNode::setNodeValue(constQString & v)

Sets the node's value tov.

See alsonodeValue().

void QDomNode::setPrefix(constQString & pre)

If the node has a namespace prefix, this function changes the namespace prefix of the node topre. Otherwise this function does nothing.

Only nodes of typeElementNode orAttributeNode can have namespaces. A namespace prefix must have be specified at creation time; it is not possible to add a namespace prefix afterwards.

QDomDocument::createElementNS()QDomDocument::createAttributeNS()

See alsoprefix(),localName(), andnamespaceURI().

QDomAttr QDomNode::toAttr() const

Converts aQDomNode into aQDomAttr. If the node is not an attribute, the returned object will benull.

See alsoisAttr().

QDomCDATASection QDomNode::toCDATASection() const

Converts aQDomNode into aQDomCDATASection. If the node is not a CDATA section, the returned object will benull.

See alsoisCDATASection().

QDomCharacterData QDomNode::toCharacterData() const

Converts aQDomNode into aQDomCharacterData. If the node is not a character data node the returned object will benull.

See alsoisCharacterData().

QDomComment QDomNode::toComment() const

Converts aQDomNode into aQDomComment. If the node is not a comment the returned object will benull.

See alsoisComment().

QDomDocument QDomNode::toDocument() const

Converts aQDomNode into aQDomDocument. If the node is not a document the returned object will benull.

See alsoisDocument().

QDomDocumentFragment QDomNode::toDocumentFragment() const

Converts aQDomNode into aQDomDocumentFragment. If the node is not a document fragment the returned object will benull.

See alsoisDocumentFragment().

QDomDocumentType QDomNode::toDocumentType() const

Converts aQDomNode into aQDomDocumentType. If the node is not a document type the returned object will benull.

See alsoisDocumentType().

QDomElement QDomNode::toElement() const

Converts aQDomNode into aQDomElement. If the node is not an element the returned object will benull.

See alsoisElement().

QDomEntity QDomNode::toEntity() const

Converts aQDomNode into aQDomEntity. If the node is not an entity the returned object will benull.

See alsoisEntity().

QDomEntityReference QDomNode::toEntityReference() const

Converts aQDomNode into aQDomEntityReference. If the node is not an entity reference, the returned object will benull.

See alsoisEntityReference().

QDomNotation QDomNode::toNotation() const

Converts aQDomNode into aQDomNotation. If the node is not a notation the returned object will benull.

See alsoisNotation().

QDomProcessingInstruction QDomNode::toProcessingInstruction() const

Converts aQDomNode into aQDomProcessingInstruction. If the node is not a processing instruction the returned object will benull.

See alsoisProcessingInstruction().

QDomText QDomNode::toText() const

Converts aQDomNode into aQDomText. If the node is not a text, the returned object will benull.

See alsoisText().

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

Returns true ifn and this DOM node are not equal; otherwise returns false.

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

Assigns a copy ofn 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, usecloneNode().

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

Returns true ifn and this DOM node are equal; otherwise returns false.

Any instance ofQDomNode acts as a reference to an underlying data structure inQDomDocument. The test for equality checks if the two references point to the same underlying node. For example:

QDomDocument document;QDomElement element1= document.documentElement();QDomElement element2= element1;

The two nodes (QDomElement is aQDomNode subclass) both refer to the document's root element, andelement1 == element2 will return true. On the other hand:

QDomElement element3= document.createElement("MyElement");QDomElement element4= document.createElement("MyElement");

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.

Related Non-Members

QTextStream &operator<<(QTextStream & str, constQDomNode & node)

Writes the XML representation of the nodenode and all its children to the streamstr.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp