📄 qdomnode.3qt
字号:
'\" t.TH QDomNode 3qt "9 December 2002" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQDomNode \- The base class for all the nodes in a DOM tree.SH SYNOPSIS\fC#include <qdom.h>\fR.PPInherited by QDomDocumentType, QDomDocument, QDomDocumentFragment, QDomCharacterData, QDomAttr, QDomElement, QDomNotation, QDomEntity, QDomEntityReference, and QDomProcessingInstruction..PP.SS "Public Members".in +1c.ti -1c.BI "enum \fBNodeType\fR { 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 }".br.ti -1c.BI "\fBQDomNode\fR ()".br.ti -1c.BI "\fBQDomNode\fR ( const QDomNode & n )".br.ti -1c.BI "QDomNode & \fBoperator=\fR ( const QDomNode & n )".br.ti -1c.BI "bool \fBoperator==\fR ( const QDomNode & n ) const".br.ti -1c.BI "bool \fBoperator!=\fR ( const QDomNode & n ) const".br.ti -1c.BI "virtual \fB~QDomNode\fR ()".br.ti -1c.BI "virtual QDomNode \fBinsertBefore\fR ( const QDomNode & newChild, const QDomNode & refChild )".br.ti -1c.BI "virtual QDomNode \fBinsertAfter\fR ( const QDomNode & newChild, const QDomNode & refChild )".br.ti -1c.BI "virtual QDomNode \fBreplaceChild\fR ( const QDomNode & newChild, const QDomNode & oldChild )".br.ti -1c.BI "virtual QDomNode \fBremoveChild\fR ( const QDomNode & oldChild )".br.ti -1c.BI "virtual QDomNode \fBappendChild\fR ( const QDomNode & newChild )".br.ti -1c.BI "virtual bool \fBhasChildNodes\fR () const".br.ti -1c.BI "virtual QDomNode \fBcloneNode\fR ( bool deep = TRUE ) const".br.ti -1c.BI "virtual void \fBnormalize\fR ()".br.ti -1c.BI "virtual bool \fBisSupported\fR ( const QString & feature, const QString & version ) const".br.ti -1c.BI "virtual QString \fBnodeName\fR () const".br.ti -1c.BI "virtual QDomNode::NodeType \fBnodeType\fR () const".br.ti -1c.BI "virtual QDomNode \fBparentNode\fR () const".br.ti -1c.BI "virtual QDomNodeList \fBchildNodes\fR () const".br.ti -1c.BI "virtual QDomNode \fBfirstChild\fR () const".br.ti -1c.BI "virtual QDomNode \fBlastChild\fR () const".br.ti -1c.BI "virtual QDomNode \fBpreviousSibling\fR () const".br.ti -1c.BI "virtual QDomNode \fBnextSibling\fR () const".br.ti -1c.BI "virtual QDomNamedNodeMap \fBattributes\fR () const".br.ti -1c.BI "virtual QDomDocument \fBownerDocument\fR () const".br.ti -1c.BI "virtual QString \fBnamespaceURI\fR () const".br.ti -1c.BI "virtual QString \fBlocalName\fR () const".br.ti -1c.BI "virtual bool \fBhasAttributes\fR () const".br.ti -1c.BI "virtual QString \fBnodeValue\fR () const".br.ti -1c.BI "virtual void \fBsetNodeValue\fR ( const QString & v )".br.ti -1c.BI "virtual QString \fBprefix\fR () const".br.ti -1c.BI "virtual void \fBsetPrefix\fR ( const QString & pre )".br.ti -1c.BI "virtual bool \fBisAttr\fR () const".br.ti -1c.BI "virtual bool \fBisCDATASection\fR () const".br.ti -1c.BI "virtual bool \fBisDocumentFragment\fR () const".br.ti -1c.BI "virtual bool \fBisDocument\fR () const".br.ti -1c.BI "virtual bool \fBisDocumentType\fR () const".br.ti -1c.BI "virtual bool \fBisElement\fR () const".br.ti -1c.BI "virtual bool \fBisEntityReference\fR () const".br.ti -1c.BI "virtual bool \fBisText\fR () const".br.ti -1c.BI "virtual bool \fBisEntity\fR () const".br.ti -1c.BI "virtual bool \fBisNotation\fR () const".br.ti -1c.BI "virtual bool \fBisProcessingInstruction\fR () const".br.ti -1c.BI "virtual bool \fBisCharacterData\fR () const".br.ti -1c.BI "virtual bool \fBisComment\fR () const".br.ti -1c.BI "QDomNode \fBnamedItem\fR ( const QString & name ) const".br.ti -1c.BI "bool \fBisNull\fR () const".br.ti -1c.BI "void \fBclear\fR ()".br.ti -1c.BI "QDomAttr \fBtoAttr\fR ()".br.ti -1c.BI "QDomCDATASection \fBtoCDATASection\fR ()".br.ti -1c.BI "QDomDocumentFragment \fBtoDocumentFragment\fR ()".br.ti -1c.BI "QDomDocument \fBtoDocument\fR ()".br.ti -1c.BI "QDomDocumentType \fBtoDocumentType\fR ()".br.ti -1c.BI "QDomElement \fBtoElement\fR ()".br.ti -1c.BI "QDomEntityReference \fBtoEntityReference\fR ()".br.ti -1c.BI "QDomText \fBtoText\fR ()".br.ti -1c.BI "QDomEntity \fBtoEntity\fR ()".br.ti -1c.BI "QDomNotation \fBtoNotation\fR ()".br.ti -1c.BI "QDomProcessingInstruction \fBtoProcessingInstruction\fR ()".br.ti -1c.BI "QDomCharacterData \fBtoCharacterData\fR ()".br.ti -1c.BI "QDomComment \fBtoComment\fR ()".br.ti -1c.BI "void \fBsave\fR ( QTextStream & str, int indent ) const".br.in -1c.SH RELATED FUNCTION DOCUMENTATION.in +1c.ti -1c.BI "QTextStream & \fBoperator<<\fR ( QTextStream & str, const QDomNode & node )".br.in -1c.SH DESCRIPTIONThe QDomNode class is the base class for all the nodes in a DOM tree..PPMany functions in the DOM return a QDomNode..PPYou can find out the type of a node using isAttr(), isCDATASection(), isDocumentFragment(), isDocument(), isDocumentType(), isElement(), isEntityReference(), isText(), isEntity(), isNotation(), isProcessingInstruction(), isCharacterData() and isComment()..PPA 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()..PPCopies 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()..PPNodes are inserted with insertBefore(), insertAfter() or appendChild(). You can replace one node with another using replaceChild() and remove a node with removeChild()..PPTo 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()..PPTo find out if a node has children use hasChildNodes() and to get a list of all of a node's children use childNodes()..PPThe 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()..PPThe document to which the node belongs is returned by ownerDocument()..PPAdjacent QDomText nodes can be merged into a single node with normalize()..PPQDomElement nodes have attributes which can be retrieved with attributes()..PPQDomElement 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()..PPYou can write the XML representation of the node to a text stream with save()..PPThe following example looks for the first element in an XML document and prints the names of all the elements that are its direct children..PP.nf.br QDomDocument d;.br d.setContent( someXML );.br QDomNode n = d.firstChild();.br while ( !n.isNull() ) {.br if ( n.isElement() ) {.br QDomElement e = n.toElement();.br cout << "Element name: " << e.tagName() << endl;.br break;.br }.br n = n.nextSibling();.br }.br.fi.PPFor further information about the Document Object Model see http://www.w3.org/TR/REC-DOM-Level-1/ and http://www.w3.org/TR/DOM-Level-2-Core/. For a more general introduction of the DOM implementation see the QDomDocument documentation..PPSee also XML..SS "Member Type Documentation".SH "QDomNode::NodeType"This enum defines the type of the node:.TP\fCQDomNode::ElementNode\fR.TP\fCQDomNode::AttributeNode\fR.TP\fCQDomNode::TextNode\fR.TP\fCQDomNode::CDATASectionNode\fR.TP\fCQDomNode::EntityReferenceNode\fR.TP\fCQDomNode::EntityNode\fR.TP\fCQDomNode::ProcessingInstructionNode\fR.TP\fCQDomNode::CommentNode\fR.TP\fCQDomNode::DocumentNode\fR.TP\fCQDomNode::DocumentTypeNode\fR.TP\fCQDomNode::DocumentFragmentNode\fR.TP\fCQDomNode::NotationNode\fR.TP\fCQDomNode::BaseNode\fR - A QDomNode object, i.e. not a QDomNode subclass..TP\fCQDomNode::CharacterDataNode\fR.SH MEMBER FUNCTION DOCUMENTATION.SH "QDomNode::QDomNode ()"Constructs a null node..SH "QDomNode::QDomNode ( const QDomNode & n )"Constructs a copy of \fIn\fR..PPThe data of the copy is shared (shallow copy): modifying one node will also change the other. If you want to make a deep copy, use cloneNode()..SH "QDomNode::~QDomNode ()\fC [virtual]\fR"Destroys the object and frees its resources..SH "QDomNode QDomNode::appendChild ( const QDomNode & newChild )\fC [virtual]\fR"Appends \fInewChild\fR as the node's last child..PPIf \fInewChild\fR is the child of another node, it is reparented to this node. If \fInewChild\fR is a child of this node, then its position in the list of children is changed..PPIf \fInewChild\fR is a QDomDocumentFragment, then the children of the fragment are removed from the fragment and appended..PPReturns a new reference to \fInewChild\fR..PPSee also insertBefore(), insertAfter(), replaceChild(), and removeChild()..SH "QDomNamedNodeMap QDomNode::attributes () const\fC [virtual]\fR"Returns a named node map of all attributes. Attributes are only provided for QDomElements..PPChanging the attributes in the map will also change the attributes of this QDomNode..PPReimplemented in QDomElement..SH "QDomNodeList QDomNode::childNodes () const\fC [virtual]\fR"Returns a list of all direct child nodes..PPMost often you will call this function on a QDomElement object..PPFor example, if the XML document looks like this:.PP.nf.br <body>.br <h1>Heading</h1>.br <p>Hello <b>you</b></p>.br </body>.br.fiThen 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..PPThe nodes in the list are not copied; so changing the nodes in the list will also change the children of this node..PPSee also firstChild() and lastChild()..SH "void QDomNode::clear ()"Converts the node into a null node; if it was not a null node before, its type and contents are deleted..PPSee also isNull()..SH "QDomNode QDomNode::cloneNode ( bool deep = TRUE ) const\fC [virtual]\fR"Creates a deep (not shallow) copy of the QDomNode..PPIf \fIdeep\fR is TRUE, then the cloning is done recursively which means that all the node's children are deep copied too. If \fIdeep\fR is FALSE only the node itself is copied and the copy will have no child nodes..SH "QDomNode QDomNode::firstChild () const\fC [virtual]\fR"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..PPSee also lastChild() and childNodes()..PPExample: xml/outliner/outlinetree.cpp.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -