source: trunk/doc/html/qdomdocument.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 36.2 KB
Line 
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"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { 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&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;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&nbsp;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 &lt;<a href="qdom-h.html">qdom.h</a>&gt;</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&nbsp;QString&nbsp;&amp;&nbsp;name )</li>
44<li class=fn>explicit <a href="#QDomDocument-3"><b>QDomDocument</b></a> ( const&nbsp;QDomDocumentType&nbsp;&amp;&nbsp;doctype )</li>
45<li class=fn><a href="#QDomDocument-4"><b>QDomDocument</b></a> ( const&nbsp;QDomDocument&nbsp;&amp;&nbsp;x )</li>
46<li class=fn>QDomDocument &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QDomDocument&nbsp;&amp;&nbsp;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&nbsp;QString&nbsp;&amp;&nbsp;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&nbsp;QString&nbsp;&amp;&nbsp;value )</li>
51<li class=fn>QDomComment <a href="#createComment"><b>createComment</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;value )</li>
52<li class=fn>QDomCDATASection <a href="#createCDATASection"><b>createCDATASection</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;value )</li>
53<li class=fn>QDomProcessingInstruction <a href="#createProcessingInstruction"><b>createProcessingInstruction</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;target, const&nbsp;QString&nbsp;&amp;&nbsp;data )</li>
54<li class=fn>QDomAttr <a href="#createAttribute"><b>createAttribute</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name )</li>
55<li class=fn>QDomEntityReference <a href="#createEntityReference"><b>createEntityReference</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name )</li>
56<li class=fn>QDomNodeList <a href="#elementsByTagName"><b>elementsByTagName</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;tagname ) const</li>
57<li class=fn>QDomNode <a href="#importNode"><b>importNode</b></a> ( const&nbsp;QDomNode&nbsp;&amp;&nbsp;importedNode, bool&nbsp;deep )</li>
58<li class=fn>QDomElement <a href="#createElementNS"><b>createElementNS</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;nsURI, const&nbsp;QString&nbsp;&amp;&nbsp;qName )</li>
59<li class=fn>QDomAttr <a href="#createAttributeNS"><b>createAttributeNS</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;nsURI, const&nbsp;QString&nbsp;&amp;&nbsp;qName )</li>
60<li class=fn>QDomNodeList <a href="#elementsByTagNameNS"><b>elementsByTagNameNS</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;nsURI, const&nbsp;QString&nbsp;&amp;&nbsp;localName )</li>
61<li class=fn>QDomElement <a href="#elementById"><b>elementById</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;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&nbsp;QCString&nbsp;&amp;&nbsp;buffer, bool&nbsp;namespaceProcessing, QString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
66<li class=fn>bool <a href="#setContent"><b>setContent</b></a> ( const&nbsp;QByteArray&nbsp;&amp;&nbsp;buffer, bool&nbsp;namespaceProcessing, QString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
67<li class=fn>bool <a href="#setContent-3"><b>setContent</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;text, bool&nbsp;namespaceProcessing, QString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
68<li class=fn>bool <a href="#setContent-4"><b>setContent</b></a> ( QIODevice&nbsp;*&nbsp;dev, bool&nbsp;namespaceProcessing, QString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
69<li class=fn>bool <a href="#setContent-5"><b>setContent</b></a> ( const&nbsp;QCString&nbsp;&amp;&nbsp;buffer, QString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
70<li class=fn>bool <a href="#setContent-6"><b>setContent</b></a> ( const&nbsp;QByteArray&nbsp;&amp;&nbsp;buffer, QString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
71<li class=fn>bool <a href="#setContent-7"><b>setContent</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;text, QString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
72<li class=fn>bool <a href="#setContent-8"><b>setContent</b></a> ( QIODevice&nbsp;*&nbsp;dev, QString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )</li>
73<li class=fn>bool <a href="#setContent-9"><b>setContent</b></a> ( QXmlInputSource&nbsp;*&nbsp;source, QXmlReader&nbsp;*&nbsp;reader, QString&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;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&nbsp;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&nbsp;indent ) const</li>
80</ul>
81<hr><a name="details"></a><h2>Detailed Description</h2>
82
83
84
85The QDomDocument class represents an XML document.
86
87<p>
88
89<p> The QDomDocument class represents the entire XML document.
90Conceptually, it is the root of the document tree, and provides
91the primary access to the document's data.
92<p> Since elements, text nodes, comments, processing instructions,
93etc., cannot exist outside the context of a document, the document
94class also contains the factory functions needed to create these
95objects. The node objects created have an <a href="qdomnode.html#ownerDocument">ownerDocument</a>() function
96which associates them with the document within whose context they
97were 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
100can be accessed using the various QDom classes. All QDom classes
101only <em>reference</em> objects in the internal tree. The internal
102objects in the DOM tree will get deleted once the last QDom
103object referencing them and the QDomDocument itself are deleted.
104<p> Creation of elements, text nodes, etc. is done using the various
105factory functions provided in this class. Using the default
106constructors of the QDom classes will only result in empty
107objects that cannot be manipulated or inserted into the Document.
108<p> The QDomDocument class has several functions for creating document
109data, 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
113that 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
115to hold parts of the document; this is useful for manipulating for
116complex documents.
117<p> The entire content of the document is set with <a href="#setContent">setContent</a>(). This
118function parses the string it is passed as an XML document and
119creates the DOM tree that represents the document. The root
120element is available using <a href="#documentElement">documentElement</a>(). The textual
121representation 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
123document using <a href="#importNode">importNode</a>().
124<p> You can obtain a list of all the elements that have a particular
125tag 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>( &amp;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 &lt;&lt; e.<a href="qdomelement.html#tagName">tagName</a>() &lt;&lt; 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
158representing 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>.
177For a more general introduction of the DOM implementation see the
178QDomDocument 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>
184Constructs an empty document.
185
186<h3 class=fn>explicit <a name="QDomDocument-2"></a>QDomDocument::QDomDocument ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name )
187</h3>
188Creates 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&nbsp;<a href="qdomdocumenttype.html">QDomDocumentType</a>&nbsp;&amp;&nbsp;doctype )
191</h3>
192Creates 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&nbsp;<a href="qdomdocument.html">QDomDocument</a>&nbsp;&amp;&nbsp;x )
196</h3>
197Constructs a copy of <em>x</em>.
198<p> The data of the copy is shared (shallow copy): modifying one node
199will 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>
204Destroys the object and frees its resources.
205
206<h3 class=fn><a href="qdomattr.html">QDomAttr</a> <a name="createAttribute"></a>QDomDocument::createAttribute ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name )
207</h3>
208Creates a new attribute called <em>name</em> that can be inserted into
209an 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&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;nsURI, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;qName )
213</h3>
214Creates a new attribute with namespace support that can be
215inserted into an element. The name of the attribute is <em>qName</em>
216and 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&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;value )
222</h3>
223Creates a new CDATA section for the string <em>value</em> that can be
224inserted 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&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;value )
228</h3>
229Creates a new comment for the string <em>value</em> that can be inserted
230into 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>
235Creates a new document fragment, that can be used to hold parts of
236the document, e.g. when doing complex manipulations of the
237document tree.
238
239<h3 class=fn><a href="qdomelement.html">QDomElement</a> <a name="createElement"></a>QDomDocument::createElement ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;tagName )
240</h3>
241Creates a new element called <em>tagName</em> that can be inserted into
242the 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&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;nsURI, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;qName )
246</h3>
247Creates a new element with namespace support that can be inserted
248into the DOM tree. The name of the element is <em>qName</em> and the
249namespace 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&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name )
255</h3>
256Creates a new entity reference called <em>name</em> that can be inserted
257into 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&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;target, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;data )
261</h3>
262Creates a new processing instruction that can be inserted into the
263document, e.g. using <a href="qdomnode.html#appendChild">QDomNode::appendChild</a>(). This function sets
264the target for the processing instruction to <em>target</em> and the
265data 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&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;value )
269</h3>
270Creates a text node for the string <em>value</em> that can be inserted
271into 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
275characters in CDATA sections. If you use this function to insert
276characters 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
278your own scheme to escape illegal characters, or you must store it in
279an 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>
284Returns 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>
288Returns the root element of the document.
289
290<h3 class=fn><a href="qdomelement.html">QDomElement</a> <a name="elementById"></a>QDomDocument::elementById ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;elementId )
291</h3>
292Returns the element whose ID is equal to <em>elementId</em>. If no
293element 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
295IDs, 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&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;tagname ) const
299</h3>
300Returns a <a href="qdomnodelist.html">QDomNodeList</a>, that contains all the elements in the
301document with the name <em>tagname</em>. The order of the node list is
302the order they are encountered in a preorder traversal of the
303element 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&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;nsURI, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;localName )
307</h3>
308Returns a <a href="qdomnodelist.html">QDomNodeList</a> that contains all the elements in the
309document 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
311encountered 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>
316Returns 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&nbsp;<a href="qdomnode.html">QDomNode</a>&nbsp;&amp;&nbsp;importedNode, bool&nbsp;deep )
319</h3>
320Imports the node <em>importedNode</em> from another document to this
321document. <em>importedNode</em> remains in the original document; this
322function creates a copy that can be used within this document.
323<p> This function returns the imported node that belongs to this
324document. The returned node has no parent. It is not possible to
325import QDomDocument and <a href="qdomdocumenttype.html">QDomDocumentType</a> nodes. In those cases
326this 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
329QDomAttr nodes are always imported and those of
330QDomEntityReference nodes are never imported.
331<p> The behavior of this function is slightly different depending on
332the 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
337set to TRUE in the generated attribute. The whole subtree
338of <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
344document fragment; otherwise it only generates an empty
345document 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
350also 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
354no way to use them since the document type is read-only in
355DOM 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
361no way to use them since the document type is read-only in
362DOM level 2.
363<tr bgcolor="#f0f0f0"> <td valign="top">QDomProcessingInstruction
364<td valign="top">The target and value of the processing instruction is
365copied 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>
377Returns 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>
382Returns <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>&nbsp;&amp; <a name="operator-eq"></a>QDomDocument::operator= ( const&nbsp;<a href="qdomdocument.html">QDomDocument</a>&nbsp;&amp;&nbsp;x )
386</h3>
387Assigns <em>x</em> to this DOM document.
388<p> The data of the copy is shared (shallow copy): modifying one node
389will 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&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;buffer, bool&nbsp;namespaceProcessing, <a href="qstring.html">QString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )
393</h3>
394This function parses the XML document from the byte array <em>buffer</em> and sets it as the content of the document. It tries to
395detect the encoding of the document as required by the XML
396specification.
397<p> If <em>namespaceProcessing</em> is TRUE, the parser recognizes
398namespaces in the XML file and sets the prefix name, local name
399and namespace URI to appropriate values. If <em>namespaceProcessing</em>
400is FALSE, the parser does no namespace processing when it reads
401the XML file.
402<p> If a parse error occurs, the function returns FALSE; otherwise it
403returns TRUE. If a parse error occurs and <em>errorMsg</em>, <em>errorLine</em> and <em>errorColumn</em> are not 0, the error message is
404placed in <em>*errorMsg</em>, the line number <em>*errorLine</em> and the
405column number in <em>*errorColumn</em>.
406<p> If <em>namespaceProcessing</em> is TRUE, the function <a href="qdomnode.html#prefix">QDomNode::prefix</a>()
407returns a string for all elements and attributes. It returns an
408empty string if the element or attribute has no prefix.
409<p> If <em>namespaceProcessing</em> is FALSE, the functions
410QDomNode::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&nbsp;<a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;buffer, bool&nbsp;namespaceProcessing, <a href="qstring.html">QString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )
415</h3>
416This 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:
419instead it assumes that the C string is UTF-8 encoded.
420
421<h3 class=fn>bool <a name="setContent-3"></a>QDomDocument::setContent ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, bool&nbsp;namespaceProcessing, <a href="qstring.html">QString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )
422</h3>
423This 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>.
425Since <em>text</em> is already a Unicode string, no encoding detection
426is done.
427
428<h3 class=fn>bool <a name="setContent-4"></a>QDomDocument::setContent ( <a href="qiodevice.html">QIODevice</a>&nbsp;*&nbsp;dev, bool&nbsp;namespaceProcessing, <a href="qstring.html">QString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )
429</h3>
430This 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&nbsp;<a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;buffer, <a href="qstring.html">QString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )
434</h3>
435This 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:
439instead it assumes that the C string is UTF-8 encoded.
440
441<h3 class=fn>bool <a name="setContent-6"></a>QDomDocument::setContent ( const&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;buffer, <a href="qstring.html">QString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )
442</h3>
443This 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&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, <a href="qstring.html">QString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )
448</h3>
449This 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>.
451Since <em>text</em> is already a Unicode string, no encoding detection
452is 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>&nbsp;*&nbsp;dev, <a href="qstring.html">QString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )
456</h3>
457This 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>&nbsp;*&nbsp;source, <a href="qxmlreader.html">QXmlReader</a>&nbsp;*&nbsp;reader, <a href="qstring.html">QString</a>&nbsp;*&nbsp;errorMsg = 0, int&nbsp;*&nbsp;errorLine = 0, int&nbsp;*&nbsp;errorColumn = 0 )
462</h3>
463This 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
465parses 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
467use certain features for parsing you can use this function to set up the
468reader 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>
473Converts the parsed document back to its textual representation
474and 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&nbsp;indent ) const
478</h3>
479This 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
481subelements.
482
483<h3 class=fn><a href="qstring.html">QString</a> <a name="toString"></a>QDomDocument::toString () const
484</h3>
485Converts 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&nbsp;indent ) const
489</h3>
490This 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
492subelements.
493
494<!-- eof -->
495<hr><p>
496This file is part of the <a href="index.html">Qt toolkit</a>.
497Copyright &copy; 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 &copy; 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>
Note: See TracBrowser for help on using the repository browser.