⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdomdocument.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
📖 第 1 页 / 共 2 页
字号:
.br    QDomElement tag = doc.createElement( "Greeting" );.br    root.appendChild( tag );.br.br    QDomText t = doc.createTextNode( "Hello World" );.br    tag.appendChild( t );.br.br    QString xml = doc.toString();.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..SH MEMBER FUNCTION DOCUMENTATION.SH "QDomDocument::QDomDocument ()"Constructs an empty document..SH "QDomDocument::QDomDocument ( const QString & name )"Creates a document and sets the name of the document type to \fIname\fR..SH "QDomDocument::QDomDocument ( const QDomDocumentType & doctype )"Creates a document with the document type \fIdoctype\fR..PPSee also QDomImplementation::createDocumentType()..SH "QDomDocument::QDomDocument ( const QDomDocument & x )"Constructs a copy of \fIx\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 "QDomDocument::~QDomDocument ()"Destroys the object and frees its resources..SH "QDomAttr QDomDocument::createAttribute ( const QString & name )"Creates a new attribute called \fIname\fR that can be inserted into an element, e.g. using QDomElement::setAttributeNode()..PPSee also createAttributeNS()..SH "QDomAttr QDomDocument::createAttributeNS ( const QString & nsURI, const QString & qName )"Creates a new attribute with namespace support that can be inserted into an element. The name of the attribute is \fIqName\fR and the namespace URI is \fInsURI\fR. This function also sets QDomNode::prefix() and QDomNode::localName() to appropriate values (depending on \fIqName\fR)..PPSee also createAttribute()..SH "QDomCDATASection QDomDocument::createCDATASection ( const QString & value )"Creates a new CDATA section for the string \fIvalue\fR that can be inserted into the document, e.g. using QDomNode::appendChild()..PPSee also QDomNode::appendChild(), QDomNode::insertBefore() and QDomNode::insertAfter()..SH "QDomComment QDomDocument::createComment ( const QString & value )"Creates a new comment for the string \fIvalue\fR that can be inserted into the document, e.g. using QDomNode::appendChild()..PPSee also QDomNode::appendChild(), QDomNode::insertBefore() and QDomNode::insertAfter()..SH "QDomDocumentFragment QDomDocument::createDocumentFragment ()"Creates a new document fragment, that can be used to hold parts of the document, e.g. when doing complex manipulations of the document tree..SH "QDomElement QDomDocument::createElement ( const QString & tagName )"Creates a new element called \fItagName\fR that can be inserted into the DOM tree, e.g. using QDomNode::appendChild()..PPSee also createElementNS(), QDomNode::appendChild(), QDomNode::insertBefore() and QDomNode::insertAfter()..SH "QDomElement QDomDocument::createElementNS ( const QString & nsURI, const QString & qName )"Creates a new element with namespace support that can be inserted into the DOM tree. The name of the element is \fIqName\fR and the namespace URI is \fInsURI\fR. This function also sets QDomNode::prefix() and QDomNode::localName() to appropriate values (depending on \fIqName\fR)..PPSee also createElement()..SH "QDomEntityReference QDomDocument::createEntityReference ( const QString & name )"Creates a new entity reference called \fIname\fR that can be inserted into the document, e.g. using QDomNode::appendChild()..PPSee also QDomNode::appendChild(), QDomNode::insertBefore() and QDomNode::insertAfter()..SH "QDomProcessingInstruction QDomDocument::createProcessingInstruction ( const QString & target, const QString & data )"Creates a new processing instruction that can be inserted into the document, e.g. using QDomNode::appendChild(). This function sets the target for the processing instruction to \fItarget\fR and the data to \fIdata\fR..PPSee also QDomNode::appendChild(), QDomNode::insertBefore() and QDomNode::insertAfter()..SH "QDomText QDomDocument::createTextNode ( const QString & value )"Creates a text node for the string \fIvalue\fR that can be inserted into the document tree, e.g. using QDomNode::appendChild()..PPSee also QDomNode::appendChild(), QDomNode::insertBefore() and QDomNode::insertAfter()..SH "QDomDocumentType QDomDocument::doctype () const"Returns the document type of this document..SH "QDomElement QDomDocument::documentElement () const"Returns the root element of the document..SH "QDomElement QDomDocument::elementById ( const QString & elementId )"Returns the element whose ID is equal to \fIelementId\fR. If no element with the ID was found, this function returns a null element..PPSince the actual version of the QDomClasses does not know which attributes are element IDs, this function returns always a null element. This may change in a future version..SH "QDomNodeList QDomDocument::elementsByTagName ( const QString & tagname ) const"Returns a QDomNodeList, that contains all the elements in the document with the name \fItagname\fR. The order of the node list is the order they are encountered in a preorder traversal of the element tree..PPSee also elementsByTagNameNS() and QDomElement::elementsByTagName()..SH "QDomNodeList QDomDocument::elementsByTagNameNS ( const QString & nsURI, const QString & localName )"Returns a QDomNodeList that contains all the elements in the document with the local name \fIlocalName\fR and a namespace URI of \fInsURI\fR. The order of the node list, is the order they are encountered in a preorder traversal of the element tree..PPSee also elementsByTagName() and QDomElement::elementsByTagNameNS()..SH "QDomImplementation QDomDocument::implementation () const"Returns a QDomImplementation object..SH "QDomNode QDomDocument::importNode ( const QDomNode & importedNode, bool deep )"Imports the node \fIimportedNode\fR from another document to this document. \fIimportedNode\fR remains in the original document; this function creates a copy of it that can be used within this document..PPThis function returns the imported node that belongs to this document. The returned node has no parent. It is not possible to import QDomDocument and QDomDocumentType nodes. In those cases this function returns a null node..PPIf \fIdeep\fR is TRUE, this function imports not only the node \fIimportedNode\fR but the whole subtree; if it is FALSE, only the \fIimportedNode\fR is imported. The argument \fIdeep\fR has no effect on QDomAttr and QDomEntityReference nodes, since the descendants of QDomAttr nodes are always imported and those of QDomEntityReference nodes are never imported..PPThe behavior of this function is slightly different depending on the node types:.TPQDomAttr - The owner element is set to 0 and the specified flag is set to TRUE on the generated attribute. The whole subtree of \fIimportedNode\fR is always imported for attribute nodes - \fIdeep\fR has no effect..TPQDomDocument - Document nodes cannot be imported..TPQDomDocumentFragment - If \fIdeep\fR is TRUE, this function imports the whole document fragment, otherwise it only generates an empty document fragment..TPQDomDocumentType - Document type nodes cannot be imported..TPQDomElement - Attributes for which QDomAttr::specified() is TRUE are also imported, other attributes are not imported. If \fIdeep\fR is TRUE, this function also imports the subtree of \fIimportedNode\fR, otherwise it imports only the element node (and some attributes, see above)..TPQDomEntity - Entity nodes can be imported, but at the moment there is no way to use them since the document type is readonly in DOM level 2..TPQDomEntityReference - Descendants of entity reference nodes are never imported - \fIdeep\fR has no effect..TPQDomNotation - Notation nodes can be imported, but at the moment there is no way to use them since the document type is readonly in DOM level 2..TPQDomProcessingInstruction - The target and value of the processing instruction is copied to the new node..TPQDomText, QDomCDATASection and QDomComment - The text is copied to the new node..PPSee also QDomElement::setAttribute(), QDomNode::insertBefore(), QDomNode::insertAfter(), QDomNode::replaceChild(), QDomNode::removeChild() and QDomNode::appendChild()..SH "bool QDomDocument::isDocument () const\fC [virtual]\fR"Returns TRUE..PPReimplemented from QDomNode..SH "QDomNode::NodeType QDomDocument::nodeType () const\fC [virtual]\fR"Returns DocumentNode..PPReimplemented from QDomNode..SH "QDomDocument & QDomDocument::operator= ( const QDomDocument & x )"Assigns \fIx\fR to this DOM document..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 "bool QDomDocument::setContent ( const QString & text, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )"This function parses the string \fItext\fR and sets it as the content of the document. If \fInamespaceProcessing\fR is TRUE, the parser recognizes namespaces in the XML file and sets the prefix name, local name and namespace URI to appropriate values. If \fInamespaceProcessing\fR is FALSE, the parser does no namespace processing when it reads the XML file..PPIf a parse error occurs, the function returns FALSE; otherwise TRUE. If a parse error occurs the error message is placed in \fI*\fR\fIerrorMsg\fR, the line number in \fI*\fR\fIerrorLine\fR and the column number in \fI*\fR\fIerrorColumn\fR. These error variables will only be populated if they are non-null..PPIf \fInamespaceProcessing\fR is TRUE, the function QDomNode::prefix() returns a string for all elements and attributes. It returns an empty string if the element or attribute has no prefix..PPIf \fInamespaceProcessing\fR is FALSE, the functions QDomNode::prefix(), QDomNode::localName() and QDomNode::namespaceURI() return a null string..PPSee also QDomNode::namespaceURI(), QDomNode::localName(), QDomNode::prefix(), QString::isNull() and QString::isEmpty()..SH "bool QDomDocument::setContent ( const QCString & buffer, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis function reads the XML document from the C string \fIbuffer\fR..SH "bool QDomDocument::setContent ( const QByteArray & buffer, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis function reads the XML document from the byte array \fIbuffer\fR..SH "bool QDomDocument::setContent ( QIODevice * dev, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis function reads the XML document from the IO device \fIdev\fR..SH "bool QDomDocument::setContent ( const QCString & buffer, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis function reads the XML document from the C string \fIbuffer\fR..PPNo namespace processing is done..SH "bool QDomDocument::setContent ( const QByteArray & buffer, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis function reads the XML document from the byte array \fIbuffer\fR..PPNo namespace processing is done..SH "bool QDomDocument::setContent ( const QString & text, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis function reads the XML document from the string \fItext\fR..PPNo namespace processing is done..SH "bool QDomDocument::setContent ( QIODevice * dev, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis function reads the XML document from the IO device \fIdev\fR..PPNo namespace processing is done..SH "QCString QDomDocument::toCString () const"Converts the parsed document back to its textual representation and returns a QCString for that is encoded in UTF-8..PPSee also toString()..SH "QString QDomDocument::toString () const"Converts the parsed document back to its textual representation..PPSee also toCString()..SH "SEE ALSO".BR http://doc.trolltech.com/qdomdocument.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qdomdocument.3qt) and the Qtversion (3.0.0).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -