Qt:Документация 4.3.2/qdomnode

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] Описание класса QDomNode
[модуль QtXml ]

Класс QDomNode является базовым классом для всех узлов в DOM дереве. Далее...

 #include <QDomNode>

От него унаследованы QDomAttr, QDomCharacterData, QDomDocument, QDomDocumentFragment, QDomDocumentType, QDomElement, QDomEntity, QDomEntityReference, QDomNotation и QDomProcessingInstruction.

Примечание: Все функции в классе реентерабельны.

[править] Открытые типы

  • enum EncodingPolicy { EncodingFromDocument, EncodingFromTextStream }
  • enum NodeType { ElementNode, AttributeNode, TextNode, CDATASectionNode, ..., CharacterDataNode }

[править] Открытые функции

[править] Связанные не-члены

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

[править] Подробное описание

Класс QDomNode является базовым классом для всех узлов в DOM дереве.

Множество фукнций в DOM возвращают QDomNode.

Вы можете выяснить тип узла с помощью isAttr(), isCDATASection(), isDocumentFragment(), isDocument(), isDocumentType(), isElement(), isEntityReference(), isText(), isEntity(), isNotation(), isProcessingInstruction(), isCharacterData() и isComment().

QDomNode может быть преобразован в один из его подклассов, используя toAttr(), toCDATASection(), toDocumentFragment(), toDocument(), toDocumentType(), toElement(), toEntityReference(), toText(), toEntity(), toNotation(), toProcessingInstruction(), toCharacterData() или toComment(). You can convert a node to a null node with clear().

Копии объектов класса QDomNode делятся своими данными с помощью прямого обмена. Это означает, что изменение одного узла приведет к изменению всех копий. Это в особенности показательно в функциях, которые возвращают QDomNode, т.е. firstChild(). Вы можете использьвать независимое (глубокое) копирование узла посредством cloneNode().

QDomNode может быть нулевым, в этом случае походя на нулевой указатель. При создании копии нулевого узла получится другой нулевой узел. Нулевой узел невозможно изменить, но возможно прикрепить другой, ненулевой, к данному объекту. В этому случае копия нулевого узла останется нулевой. Вы можете проверить, является ли узел нулевым вызовом isNull(). Пустой конструктор QDomNode (или любого из классов-наследников) создает нулевой узел.

Узлы можно добавить с помощью insertBefore(), insertAfter() или appendChild(). Вы можете заменить один узел на другой с помощью replaceChild() и удалить узел посредством removeChild().

Для перебора узлов используйте firstChild() для получения первого узла-потомка (если такой существует) и nextSibling() для получения следующего. QDomNode также реализует функции lastChild(), previousSibling() и parentNode(). Для получения первого потомка с определенным именем используйте namedItem().

Для получения информации о том, имеет ли узел потомков, используйте hasChildNodes(), а для получения списка детей - childNodes().

Имя узла и его значение (значение которого варьируется в зависимости от типа) возвращается функциями nodeName() и nodeValue() соответственно. Тип узла можно узнать с помощью nodeType(). Значение узла устанавливается посредством setNodeValue().

Документ, которому принадлежит узел, можно получить с помощью ownerDocument().

Смежный узел QDomText может быть объединен с текущим в один узел посредством normalize().

QDomElement узлы имеют атрибуты, которые можно получить через attributes().

Узлы QDomElement и QDomAttr могут поддерживать пространство имен, URI которого можно получить с помощью namespaceURI(). Их локальное имя доступно с помощью localName(), а префикс через prefix(). Префикс может быть установлен посредством setPrefix().

Вы можете записать XML представление узла в текстовый поток с помощью save().

В представленном ниже примере ищется первый элемент в XML документе и печатаются имена всех его непосредственных элементов-потомков.

 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();
 }

Для получения более подробной информации о Document Object Model смотрите http://www.w3.org/TR/REC-DOM-Level-1/ и http://www.w3.org/TR/DOM-Level-2-Core/. Для того, чтобы больше узнать о представлении DOM документа, смотрите документацию по QDomDocument.


[править] Описание типов членов

[править]
enum QDomNode::EncodingPolicy

Это перечисление устанавливает, как QDomNode::save() определяет кодировку при сериализации.


Константа Значение Описание
QDomNode::EncodingFromDocument 1 Кодировка определяется из документа.
QDomNode::EncodingFromTextStream 2 Кодировку определяется из QTextStream.

Смотрите также перегруженную функцию save(), которая учитывает EncodingPolicy.

Данное перечисление было введено в Qt 4.3.

[править]
enum QDomNode::NodeType

Перечисление определяет типы узлов:


Constant Value Description
QDomNode::ElementNode 1
QDomNode::AttributeNode 2
QDomNode::TextNode 3
QDomNode::CDATASectionNode 4
QDomNode::EntityReferenceNode 5
QDomNode::EntityNode 6
QDomNode::ProcessingInstructionNode 7
QDomNode::CommentNode 8
QDomNode::DocumentNode 9
QDomNode::DocumentTypeNode 10
QDomNode::DocumentFragmentNode 11
QDomNode::NotationNode 12
QDomNode::BaseNode 21 Объект QDomNode, т.е. не подкласс QDomNode.
QDomNode::CharacterDataNode 22

[править] Описание функций-членов

[править]
QDomNode::QDomNode ()

Создает нулевой узел.

[править]
QDomNode::QDomNode ( const QDomNode & n )

Создает копию n.

Данные в копиях общие (поверхностное копирование): изменение одного узла повлечет за собой изменение и другого. Если вы хотите использовать глубокое копирование, воспользуйтесь функцией cloneNode().

[править]
QDomNode::~QDomNode ()

Уничтожает объект и освобождает ресурсы.

[править]
QDomNode QDomNode::appendChild ( const QDomNode & newChild )

Присоединяет узел newChild в качестве последнего потомка к текущему.

Если newChild является потомком другого узла, то его предок изменяется на текущий узел. Если newChild узел является потомком данного узла, изменяется его позиция в списке детей.

Если newChild является QDomDocumentFragment, все потомки фрагмента удаляются из него и присоединяются к текущему узлу.

Если newChild является QDomElement и текущий узел является QDomDocument, уже имеющим такой элемент в качестве потомка, newChild не будет добавлен, пустой узел будет возвращен.

При вызове этой функции у нулевого узла (созданного, например, с помощью конструктора по-умолчанию) ничего не произойдет.

Спецификация DOM запрещает вставку узлов атрибутов, но из-за исторических соображений QDom позволяет это.

Смотрите также insertBefore(), insertAfter(), replaceChild() и removeChild().

[править]
QDomNamedNodeMap QDomNode::attributes () const

Возвращает словарь всех атрибутов. Атрибуты предусмотрены только для объектов QDomElement.

Изменение атрибутов в словаре приведет к изменению их и непосредственно в объекте QDomNode.

[править]
QDomNodeList QDomNode::childNodes () const

Возвращает список всех непосредственных потомков.

Наиболее часто вы будете пользоваться функцией объекта QDomElement.

Например, если XML документ выглядит следующим образом:

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

То список узлов потомков "body"-элемента будет состоять из узла, созданного тегом <h1>, и узла, созданного тегом <p>.

Узля в списке не являются копиями; потому изменение узлов в списке приведек и к изменению их в самом объекте.

Смотрите также firstChild() и lastChild().

[править]
void QDomNode::clear ()

Преобразует узел в нулевой; если до этого узел нулевым не был, его тип и содержание удаляются.

Смотрите также isNull().

[править]
QDomNode QDomNode::cloneNode ( bool deep = true ) const

Создает глубокую (не поверхностную) копию объекта QDomNode.

Если deep равен true, клонирование происходит рекурсивно, что означает, что все дети узла будут скопированны подобным же образом. Если deep равен false, будет скопирован только текущий узел, узлы-потомки скопированы не будут.

[править]
int QDomNode::columnNumber () const

Для узлов, созданных с помощью QDomDocument::setContent(), эта функция возвращает номер столбца в XML документе, где он был проанализирован. В противном случае возвращает -1.

Эта функция была введена в Qt 4.1.

Смотрите также lineNumber() и QDomDocument::setContent().

[править]
QDomNode QDomNode::firstChild () const

Возвращает первого потомка узла. Если такового нет, возвращается нулевой узел. Изменения возвращенного узла приведут и к изменениям узла в дереве документа.

Смотрите также lastChild() и childNodes().

[править]
QDomElement QDomNode::firstChildElement ( const QString & tagName = QString() ) const

Возвращает первого потомка с именем тега tagName, если tagName не пуст; в противном случае возвращает первого потомка элемента. Если вышеуказанных узлов не обнаружено, возвращается нулевой элемент.

Смотрите также lastChildElement(), previousSiblingElement(), and nextSiblingElement().

[править]
bool QDomNode::hasAttributes () const

Возвращает true, если узел имеет атрибуты; в противном случае возвращает false.

Смотрите также attributes().

[править]
bool QDomNode::hasChildNodes () const

Возвращает true, если узел имеет одного или более потомков; в противном случае возвращает false.

[править]
QDomNode QDomNode::insertAfter ( const QDomNode & newChild, const QDomNode & refChild )

Вставляет узел newChild после refChild. refChild должен быть непосредственным потомком текущего узла. Если refChild является нулевым, тогда newChild присоединяется в качестве последнего потомка.

Если newChild является потомком другого узла, текущий узел становится его предком. Если newChild является потомком текущего узла, его позиция в списке детей изменяется.

Если newChild является QDomDocumentFragment, тогда дети этого фрагмента удаляются из него и вставляются после refChild.

Возвращает новую ссылку на newChild в случае успешного завершения или нулевой узел в случае неудачи.

Спецификация DOM запрещает вставлять узлы атрибутов, но из-за исторических соображений QDom позволяет это.

Смотрите также insertBefore(), replaceChild(), removeChild() и appendChild().

[править]
QDomNode QDomNode::insertBefore ( const QDomNode & newChild, const QDomNode & refChild )

Вставляет узел newChild до refChild. refChild должен быть непосредственным потомком текущего узла. Если refChild является нулевым, тогда newChild присоединяется в качестве первого потомка.

Если newChild является потомком другого узла, текущий узел становится его предком. Если newChild является потомком текущего узла, его позиция в списке детей изменяется.

Если newChild является QDomDocumentFragment, тогда дети этого фрагмента удаляются из него и вставляются до refChild.

Возвращает новую ссылку на newChild в случае успешного завершения или нулевой узел в случае неудачи.

Спецификация DOM запрещает вставлять узлы атрибутов, но из-за исторических соображений QDom позволяет это.

Смотрите также insertAfter(), replaceChild(), removeChild() и appendChild().

[править]
bool QDomNode::isAttr () const

Возвращает true, если узел является атрибутом; в противном случае возвращает false.

Если эта функция возвращает true, это не значит, что данный объект является QDomAttribute; вы можете поулчить QDomAttribute с помощью toAttribute().

Смотрите также toAttr().

[править]
bool QDomNode::isCDATASection () const

Возвращает true, если узел является a CDATA section; в противном случае возвращает false.

Если эта функция возвращает true, это не значит, что данный объект является QDomCDATASection; вы можете получить QDomCDATASection с помощью toCDATASection().

Смотрите также toCDATASection().

[править]
bool QDomNode::isCharacterData () const

Возвращает true, если узел является a character data node; в противном случае возвращает false.

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

Смотрите также toCharacterData().

[править]
bool QDomNode::isComment () const

Возвращает true, если узел является a comment; в противном случае возвращает false.

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

Смотрите также toComment().

[править]
bool QDomNode::isDocument () const

Возвращает true, если узел является a document; в противном случае возвращает false.

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

Смотрите также toDocument().

[править]
bool QDomNode::isDocumentFragment () const

Возвращает true, если узел является a document fragment; в противном случае возвращает false.

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

Смотрите также toDocumentFragment().

[править]
bool QDomNode::isDocumentType () const

Возвращает true, если узел является a document type; в противном случае возвращает false.

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

Смотрите также toDocumentType().

[править]
bool QDomNode::isElement () const

Возвращает true, если узел является an element; в противном случае возвращает false.

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

Смотрите также toElement().

[править]
bool QDomNode::isEntity () const

Возвращает true, если узел является an entity; в противном случае возвращает false.

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

Смотрите также toEntity().

[править]
bool QDomNode::isEntityReference () const

Возвращает true, если узел является an entity reference; в противном случае возвращает false.

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

Смотрите также toEntityReference().

[править]
bool QDomNode::isNotation () const

Возвращает true, если узел является a notation; в противном случае возвращает false.

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

Смотрите также toNotation().

[править]
bool QDomNode::isNull () const

Returns true if this node is null (i.e. if it has no type or contents); в противном случае возвращает false.

[править]
bool QDomNode::isProcessingInstruction () const

Возвращает true, если узел является a processing instruction; в противном случае возвращает false.

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

Смотрите также toProcessingInstruction().

[править]
bool QDomNode::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; в противном случае возвращает false.

Смотрите также QDomImplementation::hasFeature().

[править]
bool QDomNode::isText () const

Возвращает true, если узел является a text node; в противном случае возвращает false.

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

Смотрите также toText().

[править]
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.

Смотрите также firstChild() and childNodes().

[править]
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 first child element. Returns a null element if no such child exists.

Смотрите также firstChildElement(), previousSiblingElement(), and nextSiblingElement().

[править]
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.

This function was introduced in Qt 4.1.

Смотрите также columnNumber() and QDomDocument::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 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.

QDomDocument::createAttributeNS()

Смотрите также prefix(), namespaceURI(), and QDomDocument::createElementNS().

[править]
QDomNode QDomNode::namedItem ( const QString & name ) const

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

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

Смотрите также nodeName().

[править]
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.

QDomDocument::createAttributeNS()

Смотрите также prefix(), localName(), and QDomDocument::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 this QDomNode represents the <p> tag, nextSibling() will return the node representing the <h2> tag.

Смотрите также previousSibling().

[править]
QDomElement QDomNode::nextSiblingElement ( const QString & tagName = QString() ) const

Returns the next sibilng 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.

Смотрите также firstChildElement(), previousSiblingElement(), and lastChildElement().

[править]
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().

Смотрите также nodeValue().

[править]
NodeType QDomNode::nodeType () const

Returns the type of the node.

Смотрите также toAttr(), toCDATASection(), toDocumentFragment(), toDocument(), toDocumentType(), toElement(), toEntityReference(), toText(), toEntity(), toNotation(), toProcessingInstruction(), toCharacterData(), and toComment().

[править]
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.

Смотрите также setNodeValue() and nodeName().

[править]
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).

[править]
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 which isNull() 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 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.

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

Смотрите также setPrefix(), localName(), and namespaceURI().

[править]
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 this QDomNode represents the &<p&> tag, previousSibling() will return the node representing the &<h1&> tag.

Смотрите также nextSibling().

[править]
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.

Смотрите также firstChildElement(), nextSiblingElement(), and lastChildElement().

[править]
QDomNode QDomNode::removeChild ( const QDomNode & oldChild )

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.

Смотрите также insertBefore(), insertAfter(), replaceChild(), and appendChild().

[править]
QDomNode QDomNode::replaceChild ( const QDomNode & newChild, const QDomNode & oldChild )

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.

Смотрите также insertBefore(), insertAfter(), removeChild(), and appendChild().

[править]
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.

[править]
void QDomNode::save ( QTextStream & str, int indent, EncodingPolicy encodingPolicy ) const

This is an overloaded member function, provided for convenience.

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.

This function was introduced in Qt 4.2.

[править]
void QDomNode::setNodeValue ( const QString & v )

Sets the node's value to v.

Смотрите также nodeValue().

[править]
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.

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

Смотрите также prefix(), localName(), and namespaceURI().

[править]
QDomAttr QDomNode::toAttr () const

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

Смотрите также isAttr().

[править]
QDomCDATASection QDomNode::toCDATASection () const

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

Смотрите также isCDATASection().

[править]
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.

Смотрите также isCharacterData().

[править]
QDomComment QDomNode::toComment () const

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

Смотрите также isComment().

[править]
QDomDocument QDomNode::toDocument () const

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

Смотрите также isDocument().

[править]
QDomDocumentFragment QDomNode::toDocumentFragment () const

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

Смотрите также isDocumentFragment().

[править]
QDomDocumentType QDomNode::toDocumentType () const

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

Смотрите также isDocumentType().

[править]
QDomElement QDomNode::toElement () const

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

Смотрите также isElement().

[править]
QDomEntity QDomNode::toEntity () const

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

Смотрите также isEntity().

[править]
QDomEntityReference QDomNode::toEntityReference () const

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

Смотрите также isEntityReference().

[править]
QDomNotation QDomNode::toNotation () const

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

Смотрите также isNotation().

[править]
QDomProcessingInstruction QDomNode::toProcessingInstruction () const

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

Смотрите также isProcessingInstruction().

[править]
QDomText QDomNode::toText () const

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

Смотрите также isText().

[править]
bool QDomNode::operator!= ( const QDomNode & n ) const

Returns true if n and this DOM node are not equal; в противном случае возвращает false.

[править]
QDomNode & QDomNode::operator= ( const QDomNode & n )

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

[править]
bool QDomNode::operator== ( const QDomNode & n ) const

Returns true if n and this DOM node are equal; в противном случае возвращает 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:

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

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:

 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.


[править] Связанные не-члены

[править]
QTextStream & operator<< ( QTextStream & str, const QDomNode & node )

This is an overloaded member function, provided for convenience.

Writes the XML representation of the node node and all its children to the stream str.


Copyright © 2007 Trolltech Trademarks
Qt 4.3.2