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

📄 qdomdocument.3qt

📁 Linux下的基于X11的图形开发环境。
💻 3QT
📖 第 1 页 / 共 2 页
字号:
'\" t.TH QDomDocument 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 NAMEQDomDocument \- Represents an XML document.SH SYNOPSIS\fC#include <qdom.h>\fR.PPInherits QDomNode..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQDomDocument\fR ()".br.ti -1c.BI "explicit \fBQDomDocument\fR ( const QString & name )".br.ti -1c.BI "explicit \fBQDomDocument\fR ( const QDomDocumentType & doctype )".br.ti -1c.BI "\fBQDomDocument\fR ( const QDomDocument & x )".br.ti -1c.BI "QDomDocument & \fBoperator=\fR ( const QDomDocument & x )".br.ti -1c.BI "\fB~QDomDocument\fR ()".br.ti -1c.BI "QDomElement \fBcreateElement\fR ( const QString & tagName )".br.ti -1c.BI "QDomDocumentFragment \fBcreateDocumentFragment\fR ()".br.ti -1c.BI "QDomText \fBcreateTextNode\fR ( const QString & value )".br.ti -1c.BI "QDomComment \fBcreateComment\fR ( const QString & value )".br.ti -1c.BI "QDomCDATASection \fBcreateCDATASection\fR ( const QString & value )".br.ti -1c.BI "QDomProcessingInstruction \fBcreateProcessingInstruction\fR ( const QString & target, const QString & data )".br.ti -1c.BI "QDomAttr \fBcreateAttribute\fR ( const QString & name )".br.ti -1c.BI "QDomEntityReference \fBcreateEntityReference\fR ( const QString & name )".br.ti -1c.BI "QDomNodeList \fBelementsByTagName\fR ( const QString & tagname ) const".br.ti -1c.BI "QDomNode \fBimportNode\fR ( const QDomNode & importedNode, bool deep )".br.ti -1c.BI "QDomElement \fBcreateElementNS\fR ( const QString & nsURI, const QString & qName )".br.ti -1c.BI "QDomAttr \fBcreateAttributeNS\fR ( const QString & nsURI, const QString & qName )".br.ti -1c.BI "QDomNodeList \fBelementsByTagNameNS\fR ( const QString & nsURI, const QString & localName )".br.ti -1c.BI "QDomElement \fBelementById\fR ( const QString & elementId )".br.ti -1c.BI "QDomDocumentType \fBdoctype\fR () const".br.ti -1c.BI "QDomImplementation \fBimplementation\fR () const".br.ti -1c.BI "QDomElement \fBdocumentElement\fR () const".br.ti -1c.BI "bool \fBsetContent\fR ( const QCString & buffer, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )".br.ti -1c.BI "bool \fBsetContent\fR ( const QByteArray & buffer, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )".br.ti -1c.BI "bool \fBsetContent\fR ( const QString & text, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )".br.ti -1c.BI "bool \fBsetContent\fR ( QIODevice * dev, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )".br.ti -1c.BI "bool \fBsetContent\fR ( const QCString & buffer, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )".br.ti -1c.BI "bool \fBsetContent\fR ( const QByteArray & buffer, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )".br.ti -1c.BI "bool \fBsetContent\fR ( const QString & text, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )".br.ti -1c.BI "bool \fBsetContent\fR ( QIODevice * dev, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )".br.ti -1c.BI "virtual QDomNode::NodeType \fBnodeType\fR () const".br.ti -1c.BI "virtual bool \fBisDocument\fR () const".br.ti -1c.BI "QString \fBtoString\fR () const".br.ti -1c.BI "QString \fBtoString\fR ( int indent ) const".br.ti -1c.BI "QCString \fBtoCString\fR () const".br.ti -1c.BI "QCString \fBtoCString\fR ( int indent ) const".br.in -1c.SH DESCRIPTIONThe QDomDocument class represents an XML document..PPThe QDomDocument class represents the entire XML document. Conceptually, it is the root of the document tree, and provides the primary access to the document's data..PPSince elements, text nodes, comments, processing instructions, etc., cannot exist outside the context of a document, the document class also contains the factory functions needed to create these objects. The node objects created have an ownerDocument() function which associates them with the document within whose context they were created. The DOM classes that will be used most often are QDomNode, QDomDocument, QDomElement and QDomText..PPThe parsed XML is represented internally by a tree of objects that can be accessed using the various QDom classes. All QDom classes only \fIreference\fR objects in the internal tree. The internal objects in the DOM tree will get deleted once the last QDom object referencing them and the QDomDocument itself are deleted..PPCreation of elements, text nodes, etc. is done using the various factory functions provided in this class. Using the default constructors of the QDom classes will only result in empty objects that cannot be manipulated or inserted into the Document..PPThe QDomDocument class has several functions for creating document data, for example, createElement(), createTextNode(), createComment(), createCDATASection(), createProcessingInstruction(), createAttribute() and createEntityReference(). Some of these functions have versions that support namespaces, i.e. createElementNS() and createAttributeNS(). The createDocumentFragment() function is used to hold parts of the document; this is useful for manipulating for complex documents..PPThe entire content of the document is set with setContent(). This function parses the string it is passed as an XML document and creates the DOM tree that represents the document. The root element is available using documentElement(). The textual representation of the document can be obtained using toString()..PPIt is possible to insert a node from another document into the document using importNode()..PPYou can obtain a list of all the elements that have a particular tag with elementsByTagName() or with elementsByTagNameNS()..PPThe QDom classes are typically used as follows:.PP.nf.br    QDomDocument doc( "mydocument" );.br    QFile file( "mydocument.xml" );.br    if ( !file.open( IO_ReadOnly ) ).br        return;.br    if ( !doc.setContent( &file ) ) {.br        file.close();.br        return;.br    }.br    file.close();.br.br    // print out the element names of all elements that are direct children.br    // of the outermost element..br    QDomElement docElem = doc.documentElement();.br.br    QDomNode n = docElem.firstChild();.br    while( !n.isNull() ) {.br        QDomElement e = n.toElement(); // try to convert the node to an element..br        if( !e.isNull() ) {.br            cout << e.tagName() << endl; // the node really is an element..br        }.br        n = n.nextSibling();.br    }.br.br    // Here we append a new element to the end of the document.br    QDomElement elem = doc.createElement( "img" );.br    elem.setAttribute( "src", "myimage.png" );.br    docElem.appendChild( elem );.br.fi.PPOnce \fCdoc\fR and \fCelem\fR go out of scope, the whole internal tree representing the XML document is deleted..PPTo create a document using DOM use code like this:.PP.nf.br    QDomDocument doc( "MyML" );.br    QDomElement root = doc.createElement( "MyML" );

⌨️ 快捷键说明

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