1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/xml/qdom.cpp:6043 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QDomDocument Class</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QDomDocument Class Reference<br><small>[<a href="xml.html">XML module</a>]</small></h1>
|
---|
33 |
|
---|
34 | <p>The QDomDocument class represents an XML document.
|
---|
35 | <a href="#details">More...</a>
|
---|
36 | <p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
|
---|
37 | <p><tt>#include <<a href="qdom-h.html">qdom.h</a>></tt>
|
---|
38 | <p>Inherits <a href="qdomnode.html">QDomNode</a>.
|
---|
39 | <p><a href="qdomdocument-members.html">List of all member functions.</a>
|
---|
40 | <h2>Public Members</h2>
|
---|
41 | <ul>
|
---|
42 | <li class=fn><a href="#QDomDocument"><b>QDomDocument</b></a> ()</li>
|
---|
43 | <li class=fn>explicit <a href="#QDomDocument-2"><b>QDomDocument</b></a> ( const QString & name )</li>
|
---|
44 | <li class=fn>explicit <a href="#QDomDocument-3"><b>QDomDocument</b></a> ( const QDomDocumentType & doctype )</li>
|
---|
45 | <li class=fn><a href="#QDomDocument-4"><b>QDomDocument</b></a> ( const QDomDocument & x )</li>
|
---|
46 | <li class=fn>QDomDocument & <a href="#operator-eq"><b>operator=</b></a> ( const QDomDocument & x )</li>
|
---|
47 | <li class=fn><a href="#~QDomDocument"><b>~QDomDocument</b></a> ()</li>
|
---|
48 | <li class=fn>QDomElement <a href="#createElement"><b>createElement</b></a> ( const QString & tagName )</li>
|
---|
49 | <li class=fn>QDomDocumentFragment <a href="#createDocumentFragment"><b>createDocumentFragment</b></a> ()</li>
|
---|
50 | <li class=fn>QDomText <a href="#createTextNode"><b>createTextNode</b></a> ( const QString & value )</li>
|
---|
51 | <li class=fn>QDomComment <a href="#createComment"><b>createComment</b></a> ( const QString & value )</li>
|
---|
52 | <li class=fn>QDomCDATASection <a href="#createCDATASection"><b>createCDATASection</b></a> ( const QString & value )</li>
|
---|
53 | <li class=fn>QDomProcessingInstruction <a href="#createProcessingInstruction"><b>createProcessingInstruction</b></a> ( const QString & target, const QString & data )</li>
|
---|
54 | <li class=fn>QDomAttr <a href="#createAttribute"><b>createAttribute</b></a> ( const QString & name )</li>
|
---|
55 | <li class=fn>QDomEntityReference <a href="#createEntityReference"><b>createEntityReference</b></a> ( const QString & name )</li>
|
---|
56 | <li class=fn>QDomNodeList <a href="#elementsByTagName"><b>elementsByTagName</b></a> ( const QString & tagname ) const</li>
|
---|
57 | <li class=fn>QDomNode <a href="#importNode"><b>importNode</b></a> ( const QDomNode & importedNode, bool deep )</li>
|
---|
58 | <li class=fn>QDomElement <a href="#createElementNS"><b>createElementNS</b></a> ( const QString & nsURI, const QString & qName )</li>
|
---|
59 | <li class=fn>QDomAttr <a href="#createAttributeNS"><b>createAttributeNS</b></a> ( const QString & nsURI, const QString & qName )</li>
|
---|
60 | <li class=fn>QDomNodeList <a href="#elementsByTagNameNS"><b>elementsByTagNameNS</b></a> ( const QString & nsURI, const QString & localName )</li>
|
---|
61 | <li class=fn>QDomElement <a href="#elementById"><b>elementById</b></a> ( const QString & elementId )</li>
|
---|
62 | <li class=fn>QDomDocumentType <a href="#doctype"><b>doctype</b></a> () const</li>
|
---|
63 | <li class=fn>QDomImplementation <a href="#implementation"><b>implementation</b></a> () const</li>
|
---|
64 | <li class=fn>QDomElement <a href="#documentElement"><b>documentElement</b></a> () const</li>
|
---|
65 | <li class=fn>bool <a href="#setContent-2"><b>setContent</b></a> ( const QCString & buffer, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
---|
66 | <li class=fn>bool <a href="#setContent"><b>setContent</b></a> ( const QByteArray & buffer, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
---|
67 | <li class=fn>bool <a href="#setContent-3"><b>setContent</b></a> ( const QString & text, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
---|
68 | <li class=fn>bool <a href="#setContent-4"><b>setContent</b></a> ( QIODevice * dev, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
---|
69 | <li class=fn>bool <a href="#setContent-5"><b>setContent</b></a> ( const QCString & buffer, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
---|
70 | <li class=fn>bool <a href="#setContent-6"><b>setContent</b></a> ( const QByteArray & buffer, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
---|
71 | <li class=fn>bool <a href="#setContent-7"><b>setContent</b></a> ( const QString & text, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
---|
72 | <li class=fn>bool <a href="#setContent-8"><b>setContent</b></a> ( QIODevice * dev, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
---|
73 | <li class=fn>bool <a href="#setContent-9"><b>setContent</b></a> ( QXmlInputSource * source, QXmlReader * reader, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )</li>
|
---|
74 | <li class=fn>virtual QDomNode::NodeType <a href="#nodeType"><b>nodeType</b></a> () const</li>
|
---|
75 | <li class=fn>virtual bool <a href="#isDocument"><b>isDocument</b></a> () const</li>
|
---|
76 | <li class=fn>QString <a href="#toString"><b>toString</b></a> () const</li>
|
---|
77 | <li class=fn>QString <a href="#toString-2"><b>toString</b></a> ( int indent ) const</li>
|
---|
78 | <li class=fn>QCString <a href="#toCString"><b>toCString</b></a> () const</li>
|
---|
79 | <li class=fn>QCString <a href="#toCString-2"><b>toCString</b></a> ( int indent ) const</li>
|
---|
80 | </ul>
|
---|
81 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|
85 | The QDomDocument class represents an XML document.
|
---|
86 |
|
---|
87 | <p>
|
---|
88 |
|
---|
89 | <p> The QDomDocument class represents the entire XML document.
|
---|
90 | Conceptually, it is the root of the document tree, and provides
|
---|
91 | the primary access to the document's data.
|
---|
92 | <p> Since elements, text nodes, comments, processing instructions,
|
---|
93 | etc., cannot exist outside the context of a document, the document
|
---|
94 | class also contains the factory functions needed to create these
|
---|
95 | objects. The node objects created have an <a href="qdomnode.html#ownerDocument">ownerDocument</a>() function
|
---|
96 | which associates them with the document within whose context they
|
---|
97 | were created. The DOM classes that will be used most often are
|
---|
98 | <a href="qdomnode.html">QDomNode</a>, QDomDocument, <a href="qdomelement.html">QDomElement</a> and <a href="qdomtext.html">QDomText</a>.
|
---|
99 | <p> The parsed XML is represented internally by a tree of objects that
|
---|
100 | can be accessed using the various QDom classes. All QDom classes
|
---|
101 | only <em>reference</em> objects in the internal tree. The internal
|
---|
102 | objects in the DOM tree will get deleted once the last QDom
|
---|
103 | object referencing them and the QDomDocument itself are deleted.
|
---|
104 | <p> Creation of elements, text nodes, etc. is done using the various
|
---|
105 | factory functions provided in this class. Using the default
|
---|
106 | constructors of the QDom classes will only result in empty
|
---|
107 | objects that cannot be manipulated or inserted into the Document.
|
---|
108 | <p> The QDomDocument class has several functions for creating document
|
---|
109 | data, for example, <a href="#createElement">createElement</a>(), <a href="#createTextNode">createTextNode</a>(),
|
---|
110 | <a href="#createComment">createComment</a>(), <a href="#createCDATASection">createCDATASection</a>(),
|
---|
111 | <a href="#createProcessingInstruction">createProcessingInstruction</a>(), <a href="#createAttribute">createAttribute</a>() and
|
---|
112 | <a href="#createEntityReference">createEntityReference</a>(). Some of these functions have versions
|
---|
113 | that support namespaces, i.e. <a href="#createElementNS">createElementNS</a>() and
|
---|
114 | <a href="#createAttributeNS">createAttributeNS</a>(). The <a href="#createDocumentFragment">createDocumentFragment</a>() function is used
|
---|
115 | to hold parts of the document; this is useful for manipulating for
|
---|
116 | complex documents.
|
---|
117 | <p> The entire content of the document is set with <a href="#setContent">setContent</a>(). This
|
---|
118 | function parses the string it is passed as an XML document and
|
---|
119 | creates the DOM tree that represents the document. The root
|
---|
120 | element is available using <a href="#documentElement">documentElement</a>(). The textual
|
---|
121 | representation of the document can be obtained using <a href="#toString">toString</a>().
|
---|
122 | <p> It is possible to insert a node from another document into the
|
---|
123 | document using <a href="#importNode">importNode</a>().
|
---|
124 | <p> You can obtain a list of all the elements that have a particular
|
---|
125 | tag with <a href="#elementsByTagName">elementsByTagName</a>() or with <a href="#elementsByTagNameNS">elementsByTagNameNS</a>().
|
---|
126 | <p> The QDom classes are typically used as follows:
|
---|
127 | <pre>
|
---|
128 | QDomDocument doc( "mydocument" );
|
---|
129 | <a href="qfile.html">QFile</a> file( "mydocument.xml" );
|
---|
130 | if ( !file.<a href="qfile.html#open">open</a>( <a href="qfile.html#open">IO_ReadOnly</a> ) )
|
---|
131 | return;
|
---|
132 | if ( !doc.<a href="#setContent">setContent</a>( &file ) ) {
|
---|
133 | file.<a href="qfile.html#close">close</a>();
|
---|
134 | return;
|
---|
135 | }
|
---|
136 | file.<a href="qfile.html#close">close</a>();
|
---|
137 |
|
---|
138 | // print out the element names of all elements that are direct children
|
---|
139 | // of the outermost element.
|
---|
140 | <a href="qdomelement.html">QDomElement</a> docElem = doc.<a href="#documentElement">documentElement</a>();
|
---|
141 |
|
---|
142 | <a href="qdomnode.html">QDomNode</a> n = docElem.<a href="qdomnode.html#firstChild">firstChild</a>();
|
---|
143 | while( !n.<a href="qdomnode.html#isNull">isNull</a>() ) {
|
---|
144 | <a href="qdomelement.html">QDomElement</a> e = n.<a href="qdomnode.html#toElement">toElement</a>(); // try to convert the node to an element.
|
---|
145 | if( !e.<a href="qdomnode.html#isNull">isNull</a>() ) {
|
---|
146 | cout << e.<a href="qdomelement.html#tagName">tagName</a>() << endl; // the node really is an element.
|
---|
147 | }
|
---|
148 | n = n.<a href="qdomnode.html#nextSibling">nextSibling</a>();
|
---|
149 | }
|
---|
150 |
|
---|
151 | // Here we append a new element to the end of the document
|
---|
152 | <a href="qdomelement.html">QDomElement</a> elem = doc.<a href="#createElement">createElement</a>( "img" );
|
---|
153 | elem.<a href="qdomelement.html#setAttribute">setAttribute</a>( "src", "myimage.png" );
|
---|
154 | docElem.<a href="qdomnode.html#appendChild">appendChild</a>( elem );
|
---|
155 | </pre>
|
---|
156 |
|
---|
157 | <p> Once <tt>doc</tt> and <tt>elem</tt> go out of scope, the whole internal tree
|
---|
158 | representing the XML document is deleted.
|
---|
159 | <p> To create a document using DOM use code like this:
|
---|
160 | <pre>
|
---|
161 | QDomDocument doc( "MyML" );
|
---|
162 | <a href="qdomelement.html">QDomElement</a> root = doc.<a href="#createElement">createElement</a>( "MyML" );
|
---|
163 | doc.<a href="qdomnode.html#appendChild">appendChild</a>( root );
|
---|
164 |
|
---|
165 | <a href="qdomelement.html">QDomElement</a> tag = doc.<a href="#createElement">createElement</a>( "Greeting" );
|
---|
166 | root.<a href="qdomnode.html#appendChild">appendChild</a>( tag );
|
---|
167 |
|
---|
168 | <a href="qdomtext.html">QDomText</a> t = doc.<a href="#createTextNode">createTextNode</a>( "Hello World" );
|
---|
169 | tag.<a href="qdomnode.html#appendChild">appendChild</a>( t );
|
---|
170 |
|
---|
171 | <a href="qstring.html">QString</a> xml = doc.<a href="#toString">toString</a>();
|
---|
172 | </pre>
|
---|
173 |
|
---|
174 | <p> For further information about the Document Object Model see
|
---|
175 | <a href="http://www.w3.org/TR/REC-DOM-Level-1/">http://www.w3.org/TR/REC-DOM-Level-1/</a> and
|
---|
176 | <a href="http://www.w3.org/TR/DOM-Level-2-Core/">http://www.w3.org/TR/DOM-Level-2-Core/</a>.
|
---|
177 | For a more general introduction of the DOM implementation see the
|
---|
178 | QDomDocument documentation.
|
---|
179 | <p>See also <a href="xml-tools.html">XML</a>.
|
---|
180 |
|
---|
181 | <hr><h2>Member Function Documentation</h2>
|
---|
182 | <h3 class=fn><a name="QDomDocument"></a>QDomDocument::QDomDocument ()
|
---|
183 | </h3>
|
---|
184 | Constructs an empty document.
|
---|
185 |
|
---|
186 | <h3 class=fn>explicit <a name="QDomDocument-2"></a>QDomDocument::QDomDocument ( const <a href="qstring.html">QString</a> & name )
|
---|
187 | </h3>
|
---|
188 | Creates a document and sets the name of the document type to <em>name</em>.
|
---|
189 |
|
---|
190 | <h3 class=fn>explicit <a name="QDomDocument-3"></a>QDomDocument::QDomDocument ( const <a href="qdomdocumenttype.html">QDomDocumentType</a> & doctype )
|
---|
191 | </h3>
|
---|
192 | Creates a document with the document type <em>doctype</em>.
|
---|
193 | <p> <p>See also <a href="qdomimplementation.html#createDocumentType">QDomImplementation::createDocumentType</a>().
|
---|
194 |
|
---|
195 | <h3 class=fn><a name="QDomDocument-4"></a>QDomDocument::QDomDocument ( const <a href="qdomdocument.html">QDomDocument</a> & x )
|
---|
196 | </h3>
|
---|
197 | Constructs a copy of <em>x</em>.
|
---|
198 | <p> The data of the copy is shared (shallow copy): modifying one node
|
---|
199 | will also change the other. If you want to make a <a href="shclass.html#deep-copy">deep copy</a>, use
|
---|
200 | <a href="qdomnode.html#cloneNode">cloneNode</a>().
|
---|
201 |
|
---|
202 | <h3 class=fn><a name="~QDomDocument"></a>QDomDocument::~QDomDocument ()
|
---|
203 | </h3>
|
---|
204 | Destroys the object and frees its resources.
|
---|
205 |
|
---|
206 | <h3 class=fn><a href="qdomattr.html">QDomAttr</a> <a name="createAttribute"></a>QDomDocument::createAttribute ( const <a href="qstring.html">QString</a> & name )
|
---|
207 | </h3>
|
---|
208 | Creates a new attribute called <em>name</em> that can be inserted into
|
---|
209 | an element, e.g. using <a href="qdomelement.html#setAttributeNode">QDomElement::setAttributeNode</a>().
|
---|
210 | <p> <p>See also <a href="#createAttributeNS">createAttributeNS</a>().
|
---|
211 |
|
---|
212 | <h3 class=fn><a href="qdomattr.html">QDomAttr</a> <a name="createAttributeNS"></a>QDomDocument::createAttributeNS ( const <a href="qstring.html">QString</a> & nsURI, const <a href="qstring.html">QString</a> & qName )
|
---|
213 | </h3>
|
---|
214 | Creates a new attribute with namespace support that can be
|
---|
215 | inserted into an element. The name of the attribute is <em>qName</em>
|
---|
216 | and the namespace URI is <em>nsURI</em>. This function also sets
|
---|
217 | <a href="qdomnode.html#prefix">QDomNode::prefix</a>() and <a href="qdomnode.html#localName">QDomNode::localName</a>() to appropriate values
|
---|
218 | (depending on <em>qName</em>).
|
---|
219 | <p> <p>See also <a href="#createAttribute">createAttribute</a>().
|
---|
220 |
|
---|
221 | <h3 class=fn><a href="qdomcdatasection.html">QDomCDATASection</a> <a name="createCDATASection"></a>QDomDocument::createCDATASection ( const <a href="qstring.html">QString</a> & value )
|
---|
222 | </h3>
|
---|
223 | Creates a new CDATA section for the string <em>value</em> that can be
|
---|
224 | inserted into the document, e.g. using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().
|
---|
225 | <p> <p>See also <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().
|
---|
226 |
|
---|
227 | <h3 class=fn><a href="qdomcomment.html">QDomComment</a> <a name="createComment"></a>QDomDocument::createComment ( const <a href="qstring.html">QString</a> & value )
|
---|
228 | </h3>
|
---|
229 | Creates a new comment for the string <em>value</em> that can be inserted
|
---|
230 | into the document, e.g. using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().
|
---|
231 | <p> <p>See also <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().
|
---|
232 |
|
---|
233 | <h3 class=fn><a href="qdomdocumentfragment.html">QDomDocumentFragment</a> <a name="createDocumentFragment"></a>QDomDocument::createDocumentFragment ()
|
---|
234 | </h3>
|
---|
235 | Creates a new document fragment, that can be used to hold parts of
|
---|
236 | the document, e.g. when doing complex manipulations of the
|
---|
237 | document tree.
|
---|
238 |
|
---|
239 | <h3 class=fn><a href="qdomelement.html">QDomElement</a> <a name="createElement"></a>QDomDocument::createElement ( const <a href="qstring.html">QString</a> & tagName )
|
---|
240 | </h3>
|
---|
241 | Creates a new element called <em>tagName</em> that can be inserted into
|
---|
242 | the DOM tree, e.g. using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().
|
---|
243 | <p> <p>See also <a href="#createElementNS">createElementNS</a>(), <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().
|
---|
244 |
|
---|
245 | <h3 class=fn><a href="qdomelement.html">QDomElement</a> <a name="createElementNS"></a>QDomDocument::createElementNS ( const <a href="qstring.html">QString</a> & nsURI, const <a href="qstring.html">QString</a> & qName )
|
---|
246 | </h3>
|
---|
247 | Creates a new element with namespace support that can be inserted
|
---|
248 | into the DOM tree. The name of the element is <em>qName</em> and the
|
---|
249 | namespace URI is <em>nsURI</em>. This function also sets
|
---|
250 | <a href="qdomnode.html#prefix">QDomNode::prefix</a>() and <a href="qdomnode.html#localName">QDomNode::localName</a>() to appropriate values
|
---|
251 | (depending on <em>qName</em>).
|
---|
252 | <p> <p>See also <a href="#createElement">createElement</a>().
|
---|
253 |
|
---|
254 | <h3 class=fn><a href="qdomentityreference.html">QDomEntityReference</a> <a name="createEntityReference"></a>QDomDocument::createEntityReference ( const <a href="qstring.html">QString</a> & name )
|
---|
255 | </h3>
|
---|
256 | Creates a new entity reference called <em>name</em> that can be inserted
|
---|
257 | into the document, e.g. using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().
|
---|
258 | <p> <p>See also <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().
|
---|
259 |
|
---|
260 | <h3 class=fn><a href="qdomprocessinginstruction.html">QDomProcessingInstruction</a> <a name="createProcessingInstruction"></a>QDomDocument::createProcessingInstruction ( const <a href="qstring.html">QString</a> & target, const <a href="qstring.html">QString</a> & data )
|
---|
261 | </h3>
|
---|
262 | Creates a new processing instruction that can be inserted into the
|
---|
263 | document, e.g. using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(). This function sets
|
---|
264 | the target for the processing instruction to <em>target</em> and the
|
---|
265 | data to <em>data</em>.
|
---|
266 | <p> <p>See also <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().
|
---|
267 |
|
---|
268 | <h3 class=fn><a href="qdomtext.html">QDomText</a> <a name="createTextNode"></a>QDomDocument::createTextNode ( const <a href="qstring.html">QString</a> & value )
|
---|
269 | </h3>
|
---|
270 | Creates a text node for the string <em>value</em> that can be inserted
|
---|
271 | into the document tree, e.g. using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().
|
---|
272 | <p> <b>Warning:</b> All characters within an XML document must be in the range:
|
---|
273 | <p> #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
|
---|
274 | <p> This rule also applies to characters encoded as character entities and
|
---|
275 | characters in CDATA sections. If you use this function to insert
|
---|
276 | characters outside of this range, the document will not be well-formed.
|
---|
277 | <p> If you want to store binary data in an XML document you must either use
|
---|
278 | your own scheme to escape illegal characters, or you must store it in
|
---|
279 | an external unparsed entity.
|
---|
280 | <p> <p>See also <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), and <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>().
|
---|
281 |
|
---|
282 | <h3 class=fn><a href="qdomdocumenttype.html">QDomDocumentType</a> <a name="doctype"></a>QDomDocument::doctype () const
|
---|
283 | </h3>
|
---|
284 | Returns the document type of this document.
|
---|
285 |
|
---|
286 | <h3 class=fn><a href="qdomelement.html">QDomElement</a> <a name="documentElement"></a>QDomDocument::documentElement () const
|
---|
287 | </h3>
|
---|
288 | Returns the root element of the document.
|
---|
289 |
|
---|
290 | <h3 class=fn><a href="qdomelement.html">QDomElement</a> <a name="elementById"></a>QDomDocument::elementById ( const <a href="qstring.html">QString</a> & elementId )
|
---|
291 | </h3>
|
---|
292 | Returns the element whose ID is equal to <em>elementId</em>. If no
|
---|
293 | element with the ID was found, this function returns a <a href="qdomnode.html#isNull">null element</a>.
|
---|
294 | <p> Since the QDomClasses do not know which attributes are element
|
---|
295 | IDs, this function returns always a <a href="qdomnode.html#isNull">null
|
---|
296 | element</a>. This may change in a future version.
|
---|
297 |
|
---|
298 | <h3 class=fn><a href="qdomnodelist.html">QDomNodeList</a> <a name="elementsByTagName"></a>QDomDocument::elementsByTagName ( const <a href="qstring.html">QString</a> & tagname ) const
|
---|
299 | </h3>
|
---|
300 | Returns a <a href="qdomnodelist.html">QDomNodeList</a>, that contains all the elements in the
|
---|
301 | document with the name <em>tagname</em>. The order of the node list is
|
---|
302 | the order they are encountered in a preorder traversal of the
|
---|
303 | element tree.
|
---|
304 | <p> <p>See also <a href="#elementsByTagNameNS">elementsByTagNameNS</a>() and <a href="qdomelement.html#elementsByTagName">QDomElement::elementsByTagName</a>().
|
---|
305 |
|
---|
306 | <h3 class=fn><a href="qdomnodelist.html">QDomNodeList</a> <a name="elementsByTagNameNS"></a>QDomDocument::elementsByTagNameNS ( const <a href="qstring.html">QString</a> & nsURI, const <a href="qstring.html">QString</a> & localName )
|
---|
307 | </h3>
|
---|
308 | Returns a <a href="qdomnodelist.html">QDomNodeList</a> that contains all the elements in the
|
---|
309 | document with the local name <em>localName</em> and a namespace URI of
|
---|
310 | <em>nsURI</em>. The order of the node list is the order they are
|
---|
311 | encountered in a preorder traversal of the element tree.
|
---|
312 | <p> <p>See also <a href="#elementsByTagName">elementsByTagName</a>() and <a href="qdomelement.html#elementsByTagNameNS">QDomElement::elementsByTagNameNS</a>().
|
---|
313 |
|
---|
314 | <h3 class=fn><a href="qdomimplementation.html">QDomImplementation</a> <a name="implementation"></a>QDomDocument::implementation () const
|
---|
315 | </h3>
|
---|
316 | Returns a <a href="qdomimplementation.html">QDomImplementation</a> object.
|
---|
317 |
|
---|
318 | <h3 class=fn><a href="qdomnode.html">QDomNode</a> <a name="importNode"></a>QDomDocument::importNode ( const <a href="qdomnode.html">QDomNode</a> & importedNode, bool deep )
|
---|
319 | </h3>
|
---|
320 | Imports the node <em>importedNode</em> from another document to this
|
---|
321 | document. <em>importedNode</em> remains in the original document; this
|
---|
322 | function creates a copy that can be used within this document.
|
---|
323 | <p> This function returns the imported node that belongs to this
|
---|
324 | document. The returned node has no parent. It is not possible to
|
---|
325 | import QDomDocument and <a href="qdomdocumenttype.html">QDomDocumentType</a> nodes. In those cases
|
---|
326 | this function returns a <a href="qdomnode.html#isNull">null node</a>.
|
---|
327 | <p> If <em>deep</em> is TRUE, this function imports not only the node <em>importedNode</em> but its whole subtree; if it is FALSE, only the <em>importedNode</em> is imported. The argument <em>deep</em> has no effect on
|
---|
328 | <a href="qdomattr.html">QDomAttr</a> and <a href="qdomentityreference.html">QDomEntityReference</a> nodes, since the descendents of
|
---|
329 | QDomAttr nodes are always imported and those of
|
---|
330 | QDomEntityReference nodes are never imported.
|
---|
331 | <p> The behavior of this function is slightly different depending on
|
---|
332 | the node types:
|
---|
333 | <center><table cellpadding="4" cellspacing="2" border="0">
|
---|
334 | <tr bgcolor="#a2c511"> <th valign="top">Node Type <th valign="top">Behaviour
|
---|
335 | <tr bgcolor="#f0f0f0"> <td valign="top">QDomAttr
|
---|
336 | <td valign="top">The owner element is set to 0 and the specified flag is
|
---|
337 | set to TRUE in the generated attribute. The whole subtree
|
---|
338 | of <em>importedNode</em> is always imported for attribute nodes:
|
---|
339 | <em>deep</em> has no effect.
|
---|
340 | <tr bgcolor="#d0d0d0"> <td valign="top">QDomDocument
|
---|
341 | <td valign="top">Document nodes cannot be imported.
|
---|
342 | <tr bgcolor="#f0f0f0"> <td valign="top">QDomDocumentFragment
|
---|
343 | <td valign="top">If <em>deep</em> is TRUE, this function imports the whole
|
---|
344 | document fragment; otherwise it only generates an empty
|
---|
345 | document fragment.
|
---|
346 | <tr bgcolor="#d0d0d0"> <td valign="top">QDomDocumentType
|
---|
347 | <td valign="top">Document type nodes cannot be imported.
|
---|
348 | <tr bgcolor="#f0f0f0"> <td valign="top">QDomElement
|
---|
349 | <td valign="top">Attributes for which <a href="qdomattr.html#specified">QDomAttr::specified</a>() is TRUE are
|
---|
350 | also imported, other attributes are not imported. If <em>deep</em> is TRUE, this function also imports the subtree of <em>importedNode</em>; otherwise it imports only the element node
|
---|
351 | (and some attributes, see above).
|
---|
352 | <tr bgcolor="#d0d0d0"> <td valign="top">QDomEntity
|
---|
353 | <td valign="top">Entity nodes can be imported, but at the moment there is
|
---|
354 | no way to use them since the document type is read-only in
|
---|
355 | DOM level 2.
|
---|
356 | <tr bgcolor="#f0f0f0"> <td valign="top">QDomEntityReference
|
---|
357 | <td valign="top">Descendents of entity reference nodes are never imported:
|
---|
358 | <em>deep</em> has no effect.
|
---|
359 | <tr bgcolor="#d0d0d0"> <td valign="top">QDomNotation
|
---|
360 | <td valign="top">Notation nodes can be imported, but at the moment there is
|
---|
361 | no way to use them since the document type is read-only in
|
---|
362 | DOM level 2.
|
---|
363 | <tr bgcolor="#f0f0f0"> <td valign="top">QDomProcessingInstruction
|
---|
364 | <td valign="top">The target and value of the processing instruction is
|
---|
365 | copied to the new node.
|
---|
366 | <tr bgcolor="#d0d0d0"> <td valign="top">QDomText
|
---|
367 | <td valign="top">The text is copied to the new node.
|
---|
368 | <tr bgcolor="#f0f0f0"> <td valign="top">QDomCDATASection
|
---|
369 | <td valign="top">The text is copied to the new node.
|
---|
370 | <tr bgcolor="#d0d0d0"> <td valign="top">QDomComment
|
---|
371 | <td valign="top">The text is copied to the new node.
|
---|
372 | </table></center>
|
---|
373 | <p> <p>See also <a href="qdomelement.html#setAttribute">QDomElement::setAttribute</a>(), <a href="qdomnode.html#insertBefore">QDomNode::insertBefore</a>(), <a href="qdomnode.html#insertAfter">QDomNode::insertAfter</a>(), <a href="qdomnode.html#replaceChild">QDomNode::replaceChild</a>(), <a href="qdomnode.html#removeChild">QDomNode::removeChild</a>(), and <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>().
|
---|
374 |
|
---|
375 | <h3 class=fn>bool <a name="isDocument"></a>QDomDocument::isDocument () const<tt> [virtual]</tt>
|
---|
376 | </h3>
|
---|
377 | Returns TRUE.
|
---|
378 |
|
---|
379 | <p>Reimplemented from <a href="qdomnode.html#isDocument">QDomNode</a>.
|
---|
380 | <h3 class=fn><a href="qdomnode.html#NodeType-enum">QDomNode::NodeType</a> <a name="nodeType"></a>QDomDocument::nodeType () const<tt> [virtual]</tt>
|
---|
381 | </h3>
|
---|
382 | Returns <a href="qdomnode.html#NodeType-enum">DocumentNode</a>.
|
---|
383 |
|
---|
384 | <p>Reimplemented from <a href="qdomnode.html#nodeType">QDomNode</a>.
|
---|
385 | <h3 class=fn><a href="qdomdocument.html">QDomDocument</a> & <a name="operator-eq"></a>QDomDocument::operator= ( const <a href="qdomdocument.html">QDomDocument</a> & x )
|
---|
386 | </h3>
|
---|
387 | Assigns <em>x</em> to this DOM document.
|
---|
388 | <p> The data of the copy is shared (shallow copy): modifying one node
|
---|
389 | will also change the other. If you want to make a <a href="shclass.html#deep-copy">deep copy</a>, use
|
---|
390 | <a href="qdomnode.html#cloneNode">cloneNode</a>().
|
---|
391 |
|
---|
392 | <h3 class=fn>bool <a name="setContent"></a>QDomDocument::setContent ( const <a href="qbytearray.html">QByteArray</a> & buffer, bool namespaceProcessing, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
---|
393 | </h3>
|
---|
394 | This function parses the XML document from the byte array <em>buffer</em> and sets it as the content of the document. It tries to
|
---|
395 | detect the encoding of the document as required by the XML
|
---|
396 | specification.
|
---|
397 | <p> If <em>namespaceProcessing</em> is TRUE, the parser recognizes
|
---|
398 | namespaces in the XML file and sets the prefix name, local name
|
---|
399 | and namespace URI to appropriate values. If <em>namespaceProcessing</em>
|
---|
400 | is FALSE, the parser does no namespace processing when it reads
|
---|
401 | the XML file.
|
---|
402 | <p> If a parse error occurs, the function returns FALSE; otherwise it
|
---|
403 | returns TRUE. If a parse error occurs and <em>errorMsg</em>, <em>errorLine</em> and <em>errorColumn</em> are not 0, the error message is
|
---|
404 | placed in <em>*errorMsg</em>, the line number <em>*errorLine</em> and the
|
---|
405 | column number in <em>*errorColumn</em>.
|
---|
406 | <p> If <em>namespaceProcessing</em> is TRUE, the function <a href="qdomnode.html#prefix">QDomNode::prefix</a>()
|
---|
407 | returns a string for all elements and attributes. It returns an
|
---|
408 | empty string if the element or attribute has no prefix.
|
---|
409 | <p> If <em>namespaceProcessing</em> is FALSE, the functions
|
---|
410 | QDomNode::prefix(), <a href="qdomnode.html#localName">QDomNode::localName</a>() and
|
---|
411 | <a href="qdomnode.html#namespaceURI">QDomNode::namespaceURI</a>() return <a href="qstring.html#QString-null">QString::null</a>.
|
---|
412 | <p> <p>See also <a href="qdomnode.html#namespaceURI">QDomNode::namespaceURI</a>(), <a href="qdomnode.html#localName">QDomNode::localName</a>(), <a href="qdomnode.html#prefix">QDomNode::prefix</a>(), <a href="qstring.html#isNull">QString::isNull</a>(), and <a href="qstring.html#isEmpty">QString::isEmpty</a>().
|
---|
413 |
|
---|
414 | <h3 class=fn>bool <a name="setContent-2"></a>QDomDocument::setContent ( const <a href="qcstring.html">QCString</a> & buffer, bool namespaceProcessing, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
---|
415 | </h3>
|
---|
416 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
417 | <p> This function reads the XML document from the C string <em>buffer</em>.
|
---|
418 | <p> <b>Warning:</b> This function does not try to detect the encoding:
|
---|
419 | instead it assumes that the C string is UTF-8 encoded.
|
---|
420 |
|
---|
421 | <h3 class=fn>bool <a name="setContent-3"></a>QDomDocument::setContent ( const <a href="qstring.html">QString</a> & text, bool namespaceProcessing, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
---|
422 | </h3>
|
---|
423 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
424 | <p> This function reads the XML document from the string <em>text</em>.
|
---|
425 | Since <em>text</em> is already a Unicode string, no encoding detection
|
---|
426 | is done.
|
---|
427 |
|
---|
428 | <h3 class=fn>bool <a name="setContent-4"></a>QDomDocument::setContent ( <a href="qiodevice.html">QIODevice</a> * dev, bool namespaceProcessing, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
---|
429 | </h3>
|
---|
430 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
431 | <p> This function reads the XML document from the IO device <em>dev</em>.
|
---|
432 |
|
---|
433 | <h3 class=fn>bool <a name="setContent-5"></a>QDomDocument::setContent ( const <a href="qcstring.html">QCString</a> & buffer, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
---|
434 | </h3>
|
---|
435 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
436 | <p> This function reads the XML document from the C string <em>buffer</em>.
|
---|
437 | <p> No namespace processing is performed.
|
---|
438 | <p> <b>Warning:</b> This function does not try to detect the encoding:
|
---|
439 | instead it assumes that the C string is UTF-8 encoded.
|
---|
440 |
|
---|
441 | <h3 class=fn>bool <a name="setContent-6"></a>QDomDocument::setContent ( const <a href="qbytearray.html">QByteArray</a> & buffer, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
---|
442 | </h3>
|
---|
443 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
444 | <p> This function reads the XML document from the byte array <em>buffer</em>.
|
---|
445 | <p> No namespace processing is performed.
|
---|
446 |
|
---|
447 | <h3 class=fn>bool <a name="setContent-7"></a>QDomDocument::setContent ( const <a href="qstring.html">QString</a> & text, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
---|
448 | </h3>
|
---|
449 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
450 | <p> This function reads the XML document from the string <em>text</em>.
|
---|
451 | Since <em>text</em> is already a Unicode string, no encoding detection
|
---|
452 | is performed.
|
---|
453 | <p> No namespace processing is performed either.
|
---|
454 |
|
---|
455 | <h3 class=fn>bool <a name="setContent-8"></a>QDomDocument::setContent ( <a href="qiodevice.html">QIODevice</a> * dev, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
---|
456 | </h3>
|
---|
457 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
458 | <p> This function reads the XML document from the IO device <em>dev</em>.
|
---|
459 | <p> No namespace processing is performed.
|
---|
460 |
|
---|
461 | <h3 class=fn>bool <a name="setContent-9"></a>QDomDocument::setContent ( <a href="qxmlinputsource.html">QXmlInputSource</a> * source, <a href="qxmlreader.html">QXmlReader</a> * reader, <a href="qstring.html">QString</a> * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0 )
|
---|
462 | </h3>
|
---|
463 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
464 | <p> This function reads the XML document from the <a href="qxmlinputsource.html">QXmlInputSource</a> <em>source</em> and
|
---|
465 | parses it with the <a href="qxmlreader.html">QXmlReader</a> <em>reader</em>.
|
---|
466 | <p> This function doesn't change the features of the <em>reader</em>. If you want to
|
---|
467 | use certain features for parsing you can use this function to set up the
|
---|
468 | reader appropriate.
|
---|
469 | <p> <p>See also <a href="qxmlsimplereader.html">QXmlSimpleReader</a>.
|
---|
470 |
|
---|
471 | <h3 class=fn><a href="qcstring.html">QCString</a> <a name="toCString"></a>QDomDocument::toCString () const
|
---|
472 | </h3>
|
---|
473 | Converts the parsed document back to its textual representation
|
---|
474 | and returns a <a href="qcstring.html">QCString</a> for that is encoded in UTF-8.
|
---|
475 | <p> <p>See also <a href="#toString">toString</a>().
|
---|
476 |
|
---|
477 | <h3 class=fn><a href="qcstring.html">QCString</a> <a name="toCString-2"></a>QDomDocument::toCString ( int indent ) const
|
---|
478 | </h3>
|
---|
479 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
480 | <p> This function uses <em>indent</em> as the amount of space to indent
|
---|
481 | subelements.
|
---|
482 |
|
---|
483 | <h3 class=fn><a href="qstring.html">QString</a> <a name="toString"></a>QDomDocument::toString () const
|
---|
484 | </h3>
|
---|
485 | Converts the parsed document back to its textual representation.
|
---|
486 | <p> <p>See also <a href="#toCString">toCString</a>().
|
---|
487 |
|
---|
488 | <h3 class=fn><a href="qstring.html">QString</a> <a name="toString-2"></a>QDomDocument::toString ( int indent ) const
|
---|
489 | </h3>
|
---|
490 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
491 | <p> This function uses <em>indent</em> as the amount of space to indent
|
---|
492 | subelements.
|
---|
493 |
|
---|
494 | <!-- eof -->
|
---|
495 | <hr><p>
|
---|
496 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
497 | Copyright © 1995-2007
|
---|
498 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
499 | <table width=100% cellspacing=0 border=0><tr>
|
---|
500 | <td>Copyright © 2007
|
---|
501 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
502 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
503 | </table></div></address></body>
|
---|
504 | </html>
|
---|