Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > 28b9e36e96ce34b2567ae5b47a27b2c5 > files > 638

python-qt4-doc-4.10.3-3.mga4.noarch.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QDomDocument Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QDomDocument Class Reference<br /><sup><sup>[<a href="qtxml.html">QtXml</a> module]</sup></sup></h1><p>The QDomDocument class represents an XML document. <a href="#details">More...</a></p>

<p>Inherits <a href="qdomnode.html">QDomNode</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdomdocument.html#QDomDocument">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdomdocument.html#QDomDocument-2">__init__</a></b> (<i>self</i>, QString&#160;<i>name</i>)</li><li><div class="fn" /><b><a href="qdomdocument.html#QDomDocument-3">__init__</a></b> (<i>self</i>, QDomDocumentType&#160;<i>doctype</i>)</li><li><div class="fn" /><b><a href="qdomdocument.html#QDomDocument-4">__init__</a></b> (<i>self</i>, QDomDocument&#160;<i>x</i>)</li><li><div class="fn" />QDomAttr <b><a href="qdomdocument.html#createAttribute">createAttribute</a></b> (<i>self</i>, QString&#160;<i>name</i>)</li><li><div class="fn" />QDomAttr <b><a href="qdomdocument.html#createAttributeNS">createAttributeNS</a></b> (<i>self</i>, QString&#160;<i>nsURI</i>, QString&#160;<i>qName</i>)</li><li><div class="fn" />QDomCDATASection <b><a href="qdomdocument.html#createCDATASection">createCDATASection</a></b> (<i>self</i>, QString&#160;<i>data</i>)</li><li><div class="fn" />QDomComment <b><a href="qdomdocument.html#createComment">createComment</a></b> (<i>self</i>, QString&#160;<i>data</i>)</li><li><div class="fn" />QDomDocumentFragment <b><a href="qdomdocument.html#createDocumentFragment">createDocumentFragment</a></b> (<i>self</i>)</li><li><div class="fn" />QDomElement <b><a href="qdomdocument.html#createElement">createElement</a></b> (<i>self</i>, QString&#160;<i>tagName</i>)</li><li><div class="fn" />QDomElement <b><a href="qdomdocument.html#createElementNS">createElementNS</a></b> (<i>self</i>, QString&#160;<i>nsURI</i>, QString&#160;<i>qName</i>)</li><li><div class="fn" />QDomEntityReference <b><a href="qdomdocument.html#createEntityReference">createEntityReference</a></b> (<i>self</i>, QString&#160;<i>name</i>)</li><li><div class="fn" />QDomProcessingInstruction <b><a href="qdomdocument.html#createProcessingInstruction">createProcessingInstruction</a></b> (<i>self</i>, QString&#160;<i>target</i>, QString&#160;<i>data</i>)</li><li><div class="fn" />QDomText <b><a href="qdomdocument.html#createTextNode">createTextNode</a></b> (<i>self</i>, QString&#160;<i>data</i>)</li><li><div class="fn" />QDomDocumentType <b><a href="qdomdocument.html#doctype">doctype</a></b> (<i>self</i>)</li><li><div class="fn" />QDomElement <b><a href="qdomdocument.html#documentElement">documentElement</a></b> (<i>self</i>)</li><li><div class="fn" />QDomElement <b><a href="qdomdocument.html#elementById">elementById</a></b> (<i>self</i>, QString&#160;<i>elementId</i>)</li><li><div class="fn" />QDomNodeList <b><a href="qdomdocument.html#elementsByTagName">elementsByTagName</a></b> (<i>self</i>, QString&#160;<i>tagname</i>)</li><li><div class="fn" />QDomNodeList <b><a href="qdomdocument.html#elementsByTagNameNS">elementsByTagNameNS</a></b> (<i>self</i>, QString&#160;<i>nsURI</i>, QString&#160;<i>localName</i>)</li><li><div class="fn" />QDomImplementation <b><a href="qdomdocument.html#implementation">implementation</a></b> (<i>self</i>)</li><li><div class="fn" />QDomNode <b><a href="qdomdocument.html#importNode">importNode</a></b> (<i>self</i>, QDomNode&#160;<i>importedNode</i>, bool&#160;<i>deep</i>)</li><li><div class="fn" />QDomNode.NodeType <b><a href="qdomdocument.html#nodeType">nodeType</a></b> (<i>self</i>)</li><li><div class="fn" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) <b><a href="qdomdocument.html#setContent">setContent</a></b> (<i>self</i>, QByteArray&#160;<i>data</i>, bool&#160;<i>namespaceProcessing</i>)</li><li><div class="fn" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) <b><a href="qdomdocument.html#setContent-2">setContent</a></b> (<i>self</i>, QString&#160;<i>text</i>, bool&#160;<i>namespaceProcessing</i>)</li><li><div class="fn" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) <b><a href="qdomdocument.html#setContent-3">setContent</a></b> (<i>self</i>, QIODevice&#160;<i>dev</i>, bool&#160;<i>namespaceProcessing</i>)</li><li><div class="fn" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) <b><a href="qdomdocument.html#setContent-4">setContent</a></b> (<i>self</i>, QXmlInputSource&#160;<i>source</i>, bool&#160;<i>namespaceProcessing</i>)</li><li><div class="fn" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) <b><a href="qdomdocument.html#setContent-5">setContent</a></b> (<i>self</i>, QByteArray&#160;<i>buffer</i>)</li><li><div class="fn" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) <b><a href="qdomdocument.html#setContent-6">setContent</a></b> (<i>self</i>, QString&#160;<i>text</i>)</li><li><div class="fn" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) <b><a href="qdomdocument.html#setContent-7">setContent</a></b> (<i>self</i>, QIODevice&#160;<i>dev</i>)</li><li><div class="fn" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) <b><a href="qdomdocument.html#setContent-8">setContent</a></b> (<i>self</i>, QXmlInputSource&#160;<i>source</i>, QXmlReader&#160;<i>reader</i>)</li><li><div class="fn" />QByteArray <b><a href="qdomdocument.html#toByteArray">toByteArray</a></b> (<i>self</i>, int&#160;<i>indent</i>&#160;=&#160;1)</li><li><div class="fn" />QString <b><a href="qdomdocument.html#toString">toString</a></b> (<i>self</i>, int&#160;<i>indent</i>&#160;=&#160;1)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QDomDocument class represents an XML document.</p>
<p>The 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.</p>
<p>Since 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 <a href="qdomnode.html#ownerDocument">ownerDocument</a>() function which
associates them with the document within whose context they were
created. The DOM classes that will be used most often are <a href="qdomnode.html">QDomNode</a>, QDomDocument, <a href="qdomelement.html">QDomElement</a> and <a href="qdomtext.html">QDomText</a>.</p>
<p>The parsed XML is represented internally by a tree of objects
that can be accessed using the various QDom classes. All QDom
classes only <i>reference</i> 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.</p>
<p>Creation 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.</p>
<p>The QDomDocument class has several functions for creating
document data, for example, <a href="qdomdocument.html#createElement">createElement</a>(), <a href="qdomdocument.html#createTextNode">createTextNode</a>(), <a href="qdomdocument.html#createComment">createComment</a>(), <a href="qdomdocument.html#createCDATASection">createCDATASection</a>(),
<a href="qdomdocument.html#createProcessingInstruction">createProcessingInstruction</a>(),
<a href="qdomdocument.html#createAttribute">createAttribute</a>()
and <a href="qdomdocument.html#createEntityReference">createEntityReference</a>().
Some of these functions have versions that support namespaces, i.e.
<a href="qdomdocument.html#createElementNS">createElementNS</a>()
and <a href="qdomdocument.html#createAttributeNS">createAttributeNS</a>(). The
<a href="qdomdocument.html#createDocumentFragment">createDocumentFragment</a>()
function is used to hold parts of the document; this is useful for
manipulating for complex documents.</p>
<p>The entire content of the document is set with <a href="qdomdocument.html#setContent">setContent</a>(). 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 <a href="qdomdocument.html#documentElement">documentElement</a>(). The
textual representation of the document can be obtained using
<a href="qdomdocument.html#toString">toString</a>().</p>
<p><b>Note:</b> The DOM tree might end up reserving a lot of memory
if the XML document is big. For big XML documents, the <a href="qxmlstreamreader.html">QXmlStreamReader</a> or the <a href="qxmlquery.html">QXmlQuery</a> classes might be better
solutions.</p>
<p>It is possible to insert a node from another document into the
document using <a href="qdomdocument.html#importNode">importNode</a>().</p>
<p>You can obtain a list of all the elements that have a particular
tag with <a href="qdomdocument.html#elementsByTagName">elementsByTagName</a>() or
with <a href="qdomdocument.html#elementsByTagNameNS">elementsByTagNameNS</a>().</p>
<p>The QDom classes are typically used as follows:</p>
<pre class="cpp">
 <span class="type">QDomDocument</span> doc(<span class="string">"mydocument"</span>);
 <span class="type"><a href="qfile.html">QFile</a></span> file(<span class="string">"mydocument.xml"</span>);
 <span class="keyword">if</span> (<span class="operator">!</span>file<span class="operator">.</span>open(<span class="type"><a href="qiodevice.html">QIODevice</a></span><span class="operator">.</span>ReadOnly))
     <span class="keyword">return</span>;
 <span class="keyword">if</span> (<span class="operator">!</span>doc<span class="operator">.</span>setContent(<span class="operator">&amp;</span>file)) {
     file<span class="operator">.</span>close();
     <span class="keyword">return</span>;
 }
 file<span class="operator">.</span>close();

 <span class="comment">// print out the element names of all elements that are direct children</span>
 <span class="comment">// of the outermost element.</span>
 <span class="type"><a href="qdomelement.html">QDomElement</a></span> docElem <span class="operator">=</span> doc<span class="operator">.</span><a href="qdomdocument.html#documentElement">documentElement</a>();

 <span class="type"><a href="qdomnode.html">QDomNode</a></span> n <span class="operator">=</span> docElem<span class="operator">.</span><a href="qdomnode.html#firstChild">firstChild</a>();
 <span class="keyword">while</span>(<span class="operator">!</span>n<span class="operator">.</span>isNull()) {
     <span class="type"><a href="qdomelement.html">QDomElement</a></span> e <span class="operator">=</span> n<span class="operator">.</span>toElement(); <span class="comment">// try to convert the node to an element.</span>
     <span class="keyword">if</span>(<span class="operator">!</span>e<span class="operator">.</span>isNull()) {
         cout <span class="operator">&lt;</span><span class="operator">&lt;</span> <a href="qtcore.html#qPrintable">qPrintable</a>(e<span class="operator">.</span>tagName()) <span class="operator">&lt;</span><span class="operator">&lt;</span> endl; <span class="comment">// the node really is an element.</span>
     }
     n <span class="operator">=</span> n<span class="operator">.</span>nextSibling();
 }

 <span class="comment">// Here we append a new element to the end of the document</span>
 <span class="type"><a href="qdomelement.html">QDomElement</a></span> elem <span class="operator">=</span> doc<span class="operator">.</span><a href="qdomdocument.html#createElement">createElement</a>(<span class="string">"img"</span>);
 elem<span class="operator">.</span>setAttribute(<span class="string">"src"</span><span class="operator">,</span> <span class="string">"myimage.png"</span>);
 docElem<span class="operator">.</span><a href="qdomnode.html#appendChild">appendChild</a>(elem);
</pre>
<p>Once <tt>doc</tt> and <tt>elem</tt> go out of scope, the whole
internal tree representing the XML document is deleted.</p>
<p>To create a document using DOM use code like this:</p>
<pre class="cpp">
 <span class="type">QDomDocument</span> doc(<span class="string">"MyML"</span>);
 <span class="type"><a href="qdomelement.html">QDomElement</a></span> root <span class="operator">=</span> doc<span class="operator">.</span><a href="qdomdocument.html#createElement">createElement</a>(<span class="string">"MyML"</span>);
 doc<span class="operator">.</span><a href="qdomnode.html#appendChild">appendChild</a>(root);

 <span class="type"><a href="qdomelement.html">QDomElement</a></span> tag <span class="operator">=</span> doc<span class="operator">.</span><a href="qdomdocument.html#createElement">createElement</a>(<span class="string">"Greeting"</span>);
 root<span class="operator">.</span><a href="qdomnode.html#appendChild">appendChild</a>(tag);

 <span class="type"><a href="qdomtext.html">QDomText</a></span> t <span class="operator">=</span> doc<span class="operator">.</span><a href="qdomdocument.html#createTextNode">createTextNode</a>(<span class="string">"Hello World"</span>);
 tag<span class="operator">.</span><a href="qdomnode.html#appendChild">appendChild</a>(t);

 <span class="type"><a href="qstring.html">QString</a></span> xml <span class="operator">=</span> doc<span class="operator">.</span><a href="qdomdocument.html#toString">toString</a>();
</pre>
<p>For further information about the Document Object Model see the
Document Object Model (DOM) <a href="http://www.w3.org/TR/REC-DOM-Level-1/">Level 1</a> and <a href="http://www.w3.org/TR/DOM-Level-2-Core/">Level 2 Core</a>
Specifications.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDomDocument" />QDomDocument.__init__ (<i>self</i>)</h3><p>Constructs an empty document.</p>


<h3 class="fn"><a name="QDomDocument-2" />QDomDocument.__init__ (<i>self</i>, QString&#160;<i>name</i>)</h3><p>Creates a document and sets the name of the document type to
<i>name</i>.</p>


<h3 class="fn"><a name="QDomDocument-3" />QDomDocument.__init__ (<i>self</i>, <a href="qdomdocumenttype.html">QDomDocumentType</a>&#160;<i>doctype</i>)</h3><p>Creates a document with the document type <i>doctype</i>.</p>
<p><b>See also</b> <a href="qdomimplementation.html#createDocumentType">QDomImplementation.createDocumentType</a>().</p>


<h3 class="fn"><a name="QDomDocument-4" />QDomDocument.__init__ (<i>self</i>, <a href="qdomdocument.html">QDomDocument</a>&#160;<i>x</i>)</h3><p>Constructs a copy of <i>x</i>.</p>
<p>The 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 <a href="qdomnode.html#cloneNode">cloneNode</a>().</p>


<h3 class="fn"><a name="createAttribute" /><a href="qdomattr.html">QDomAttr</a> QDomDocument.createAttribute (<i>self</i>, QString&#160;<i>name</i>)</h3><p>Creates a new attribute called <i>name</i> that can be inserted
into an element, e.g. using <a href="qdomelement.html#setAttributeNode">QDomElement.setAttributeNode</a>().</p>
<p>If <i>name</i> is not a valid XML name, the behavior of this
function is governed by <a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation.InvalidDataPolicy</a>.</p>
<p><b>See also</b> <a href="qdomdocument.html#createAttributeNS">createAttributeNS</a>().</p>


<h3 class="fn"><a name="createAttributeNS" /><a href="qdomattr.html">QDomAttr</a> QDomDocument.createAttributeNS (<i>self</i>, QString&#160;<i>nsURI</i>, QString&#160;<i>qName</i>)</h3><p>Creates a new attribute with namespace support that can be
inserted into an element. The name of the attribute is <i>qName</i>
and the namespace URI is <i>nsURI</i>. This function also sets
<a href="qdomnode.html#prefix">QDomNode.prefix</a>() and <a href="qdomnode.html#localName">QDomNode.localName</a>() to appropriate
values (depending on <i>qName</i>).</p>
<p>If <i>qName</i> is not a valid XML name, the behavior of this
function is governed by <a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation.InvalidDataPolicy</a>.</p>
<p><b>See also</b> <a href="qdomdocument.html#createAttribute">createAttribute</a>().</p>


<h3 class="fn"><a name="createCDATASection" /><a href="qdomcdatasection.html">QDomCDATASection</a> QDomDocument.createCDATASection (<i>self</i>, QString&#160;<i>data</i>)</h3><p>Creates a new CDATA section for the string <i>value</i> that can
be inserted into the document, e.g. using <a href="qdomnode.html#appendChild">QDomNode.appendChild</a>().</p>
<p>If <i>value</i> contains characters which cannot be stored in a
CDATA section, the behavior of this function is governed by
<a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation.InvalidDataPolicy</a>.</p>
<p><b>See also</b> <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>().</p>


<h3 class="fn"><a name="createComment" /><a href="qdomcomment.html">QDomComment</a> QDomDocument.createComment (<i>self</i>, QString&#160;<i>data</i>)</h3><p>Creates a new comment for the string <i>value</i> that can be
inserted into the document, e.g. using <a href="qdomnode.html#appendChild">QDomNode.appendChild</a>().</p>
<p>If <i>value</i> contains characters which cannot be stored in an
XML comment, the behavior of this function is governed by <a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation.InvalidDataPolicy</a>.</p>
<p><b>See also</b> <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>().</p>


<h3 class="fn"><a name="createDocumentFragment" /><a href="qdomdocumentfragment.html">QDomDocumentFragment</a> QDomDocument.createDocumentFragment (<i>self</i>)</h3><p>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.</p>


<h3 class="fn"><a name="createElement" /><a href="qdomelement.html">QDomElement</a> QDomDocument.createElement (<i>self</i>, QString&#160;<i>tagName</i>)</h3><p>Creates a new element called <i>tagName</i> that can be inserted
into the DOM tree, e.g. using <a href="qdomnode.html#appendChild">QDomNode.appendChild</a>().</p>
<p>If <i>tagName</i> is not a valid XML name, the behavior of this
function is governed by <a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation.InvalidDataPolicy</a>.</p>
<p><a href="qdomnode.html#insertAfter">QDomNode.insertAfter</a>()</p>
<p><b>See also</b> <a href="qdomdocument.html#createElementNS">createElementNS</a>(), <a href="qdomnode.html#appendChild">QDomNode.appendChild</a>(), and
<a href="qdomnode.html#insertBefore">QDomNode.insertBefore</a>().</p>


<h3 class="fn"><a name="createElementNS" /><a href="qdomelement.html">QDomElement</a> QDomDocument.createElementNS (<i>self</i>, QString&#160;<i>nsURI</i>, QString&#160;<i>qName</i>)</h3><p>Creates a new element with namespace support that can be
inserted into the DOM tree. The name of the element is <i>qName</i>
and the namespace URI is <i>nsURI</i>. This function also sets
<a href="qdomnode.html#prefix">QDomNode.prefix</a>() and <a href="qdomnode.html#localName">QDomNode.localName</a>() to appropriate
values (depending on <i>qName</i>).</p>
<p>If <i>qName</i> is an empty string, returns a null element
regardless of whether the invalid data policy is set.</p>
<p><b>See also</b> <a href="qdomdocument.html#createElement">createElement</a>().</p>


<h3 class="fn"><a name="createEntityReference" /><a href="qdomentityreference.html">QDomEntityReference</a> QDomDocument.createEntityReference (<i>self</i>, QString&#160;<i>name</i>)</h3><p>Creates a new entity reference called <i>name</i> that can be
inserted into the document, e.g. using <a href="qdomnode.html#appendChild">QDomNode.appendChild</a>().</p>
<p>If <i>name</i> is not a valid XML name, the behavior of this
function is governed by <a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation.InvalidDataPolicy</a>.</p>
<p><b>See also</b> <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>().</p>


<h3 class="fn"><a name="createProcessingInstruction" /><a href="qdomprocessinginstruction.html">QDomProcessingInstruction</a> QDomDocument.createProcessingInstruction (<i>self</i>, QString&#160;<i>target</i>, QString&#160;<i>data</i>)</h3><p>Creates a new processing instruction that can be inserted into
the document, e.g. using <a href="qdomnode.html#appendChild">QDomNode.appendChild</a>(). This
function sets the target for the processing instruction to
<i>target</i> and the data to <i>data</i>.</p>
<p>If <i>target</i> is not a valid XML name, or data if contains
characters which cannot appear in a processing instruction, the
behavior of this function is governed by <a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation.InvalidDataPolicy</a>.</p>
<p><b>See also</b> <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>().</p>


<h3 class="fn"><a name="createTextNode" /><a href="qdomtext.html">QDomText</a> QDomDocument.createTextNode (<i>self</i>, QString&#160;<i>data</i>)</h3><p>Creates a text node for the string <i>value</i> that can be
inserted into the document tree, e.g. using <a href="qdomnode.html#appendChild">QDomNode.appendChild</a>().</p>
<p>If <i>value</i> contains characters which cannot be stored as
character data of an XML document (even in the form of character
references), the behavior of this function is governed by <a href="qdomimplementation.html#InvalidDataPolicy-enum">QDomImplementation.InvalidDataPolicy</a>.</p>
<p><b>See also</b> <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>().</p>


<h3 class="fn"><a name="doctype" /><a href="qdomdocumenttype.html">QDomDocumentType</a> QDomDocument.doctype (<i>self</i>)</h3><p>Returns the document type of this document.</p>


<h3 class="fn"><a name="documentElement" /><a href="qdomelement.html">QDomElement</a> QDomDocument.documentElement (<i>self</i>)</h3><p>Returns the root element of the document.</p>


<h3 class="fn"><a name="elementById" /><a href="qdomelement.html">QDomElement</a> QDomDocument.elementById (<i>self</i>, QString&#160;<i>elementId</i>)</h3><p>Returns the element whose ID is equal to <i>elementId</i>. If no
element with the ID was found, this function returns a <a href="qdomnode.html#isNull">null element</a>.</p>
<p>Since the QDomClasses do not know which attributes are element
IDs, this function returns always a <a href="qdomnode.html#isNull">null element</a>. This may change in a
future version.</p>


<h3 class="fn"><a name="elementsByTagName" /><a href="qdomnodelist.html">QDomNodeList</a> QDomDocument.elementsByTagName (<i>self</i>, QString&#160;<i>tagname</i>)</h3><p>Returns a <a href="qdomnodelist.html">QDomNodeList</a>, that
contains all the elements in the document with the name
<i>tagname</i>. The order of the node list is the order they are
encountered in a preorder traversal of the element tree.</p>
<p><b>See also</b> <a href="qdomdocument.html#elementsByTagNameNS">elementsByTagNameNS</a>()
and <a href="qdomelement.html#elementsByTagName">QDomElement.elementsByTagName</a>().</p>


<h3 class="fn"><a name="elementsByTagNameNS" /><a href="qdomnodelist.html">QDomNodeList</a> QDomDocument.elementsByTagNameNS (<i>self</i>, QString&#160;<i>nsURI</i>, QString&#160;<i>localName</i>)</h3><p>Returns a <a href="qdomnodelist.html">QDomNodeList</a> that
contains all the elements in the document with the local name
<i>localName</i> and a namespace URI of <i>nsURI</i>. The order of
the node list is the order they are encountered in a preorder
traversal of the element tree.</p>
<p><b>See also</b> <a href="qdomdocument.html#elementsByTagName">elementsByTagName</a>() and
<a href="qdomelement.html#elementsByTagNameNS">QDomElement.elementsByTagNameNS</a>().</p>


<h3 class="fn"><a name="implementation" /><a href="qdomimplementation.html">QDomImplementation</a> QDomDocument.implementation (<i>self</i>)</h3><p>Returns a <a href="qdomimplementation.html">QDomImplementation</a> object.</p>


<h3 class="fn"><a name="importNode" /><a href="qdomnode.html">QDomNode</a> QDomDocument.importNode (<i>self</i>, <a href="qdomnode.html">QDomNode</a>&#160;<i>importedNode</i>, bool&#160;<i>deep</i>)</h3><p>Imports the node <i>importedNode</i> from another document to
this document. <i>importedNode</i> remains in the original
document; this function creates a copy that can be used within this
document.</p>
<p>This function returns the imported node that belongs to this
document. The returned node has no parent. It is not possible to
import <a href="qdomdocument.html">QDomDocument</a> and <a href="qdomdocumenttype.html">QDomDocumentType</a> nodes. In those cases
this function returns a <a href="qdomnode.html#isNull">null
node</a>.</p>
<p>If <i>deep</i> is true, this function imports not only the node
<i>importedNode</i> but its whole subtree; if it is false, only the
<i>importedNode</i> is imported. The argument <i>deep</i> has no
effect on <a href="qdomattr.html">QDomAttr</a> and <a href="qdomentityreference.html">QDomEntityReference</a> nodes, since the
descendants of <a href="qdomattr.html">QDomAttr</a> nodes are
always imported and those of <a href="qdomentityreference.html">QDomEntityReference</a> nodes are never
imported.</p>
<p>The behavior of this function is slightly different depending on
the node types:</p>
<table class="generic">
<thead>
<tr class="qt-style">
<th>Node Type</th>
<th>Behavior</th>
</tr>
</thead>
<tr class="odd" valign="top">
<td><a href="qdomattr.html">QDomAttr</a></td>
<td>The owner element is set to 0 and the specified flag is set to
true in the generated attribute. The whole subtree of
<i>importedNode</i> is always imported for attribute nodes:
<i>deep</i> has no effect.</td>
</tr>
<tr class="even" valign="top">
<td><a href="qdomdocument.html">QDomDocument</a></td>
<td>Document nodes cannot be imported.</td>
</tr>
<tr class="odd" valign="top">
<td><a href="qdomdocumentfragment.html">QDomDocumentFragment</a></td>
<td>If <i>deep</i> is true, this function imports the whole
document fragment; otherwise it only generates an empty document
fragment.</td>
</tr>
<tr class="even" valign="top">
<td><a href="qdomdocumenttype.html">QDomDocumentType</a></td>
<td>Document type nodes cannot be imported.</td>
</tr>
<tr class="odd" valign="top">
<td><a href="qdomelement.html">QDomElement</a></td>
<td>Attributes for which <a href="qdomattr.html#specified">QDomAttr.specified</a>() is true are
also imported, other attributes are not imported. If <i>deep</i> is
true, this function also imports the subtree of
<i>importedNode</i>; otherwise it imports only the element node
(and some attributes, see above).</td>
</tr>
<tr class="even" valign="top">
<td><a href="qdomentity.html">QDomEntity</a></td>
<td>Entity nodes can be imported, but at the moment there is no way
to use them since the document type is read-only in DOM level
2.</td>
</tr>
<tr class="odd" valign="top">
<td><a href="qdomentityreference.html">QDomEntityReference</a></td>
<td>Descendants of entity reference nodes are never imported:
<i>deep</i> has no effect.</td>
</tr>
<tr class="even" valign="top">
<td><a href="qdomnotation.html">QDomNotation</a></td>
<td>Notation nodes can be imported, but at the moment there is no
way to use them since the document type is read-only in DOM level
2.</td>
</tr>
<tr class="odd" valign="top">
<td><a href="qdomprocessinginstruction.html">QDomProcessingInstruction</a></td>
<td>The target and value of the processing instruction is copied to
the new node.</td>
</tr>
<tr class="even" valign="top">
<td><a href="qdomtext.html">QDomText</a></td>
<td>The text is copied to the new node.</td>
</tr>
<tr class="odd" valign="top">
<td><a href="qdomcdatasection.html">QDomCDATASection</a></td>
<td>The text is copied to the new node.</td>
</tr>
<tr class="even" valign="top">
<td><a href="qdomcomment.html">QDomComment</a></td>
<td>The text is copied to the new node.</td>
</tr>
</table>
<p><a href="qdomnode.html#insertAfter">QDomNode.insertAfter</a>()
<a href="qdomnode.html#replaceChild">QDomNode.replaceChild</a>()
<a href="qdomnode.html#removeChild">QDomNode.removeChild</a>()
<a href="qdomnode.html#appendChild">QDomNode.appendChild</a>()</p>
<p><b>See also</b> <a href="qdomelement.html#setAttribute">QDomElement.setAttribute</a>() and
<a href="qdomnode.html#insertBefore">QDomNode.insertBefore</a>().</p>


<h3 class="fn"><a name="nodeType" /><a href="qdomnode.html#NodeType-enum">QDomNode.NodeType</a> QDomDocument.nodeType (<i>self</i>)</h3><p>Returns <tt>DocumentNode</tt>.</p>


<h3 class="fn"><a name="setContent" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) QDomDocument.setContent (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>data</i>, bool&#160;<i>namespaceProcessing</i>)</h3><p>This function parses the XML document from the byte array
<i>data</i> and sets it as the content of the document. It tries to
detect the encoding of the document as required by the XML
specification.</p>
<p>If <i>namespaceProcessing</i> is true, the parser recognizes
namespaces in the XML file and sets the prefix name, local name and
namespace URI to appropriate values. If <i>namespaceProcessing</i>
is false, the parser does no namespace processing when it reads the
XML file.</p>
<p>If a parse error occurs, this function returns false and the
error message is placed in <tt>*</tt><i>errorMsg</i>, the line
number in <tt>*</tt><i>errorLine</i> and the column number in
<tt>*</tt><i>errorColumn</i> (unless the associated pointer is set
to 0); otherwise this function returns true. The various error
messages are described in the <a href="qxmlparseexception.html">QXmlParseException</a> class
documentation. Note that, if you want to display these error
messages to your application's users, they will be displayed in
English unless they are explicitly translated.</p>
<p>If <i>namespaceProcessing</i> is true, the function <a href="qdomnode.html#prefix">QDomNode.prefix</a>() returns a string for
all elements and attributes. It returns an empty string if the
element or attribute has no prefix.</p>
<p>Text nodes consisting only of whitespace are stripped and won't
appear in the <a href="qdomdocument.html">QDomDocument</a>. If this
behavior is not desired, one can use the setContent() overload that
allows a <a href="qxmlreader.html">QXmlReader</a> to be
supplied.</p>
<p>If <i>namespaceProcessing</i> is false, the functions <a href="qdomnode.html#prefix">QDomNode.prefix</a>(), <a href="qdomnode.html#localName">QDomNode.localName</a>() and <a href="qdomnode.html#namespaceURIx">QDomNode.namespaceURI</a>() return
an empty string.</p>
<p>Entity references are handled as follows:</p>
<ul>
<li>References to internal general entities and character entities
occurring in the content are included. The result is a <a href="qdomtext.html">QDomText</a> node with the references replaced by
their corresponding entity values.</li>
<li>References to parameter entities occurring in the internal
subset are included. The result is a <a href="qdomdocumenttype.html">QDomDocumentType</a> node which contains
entity and notation declarations with the references replaced by
their corresponding entity values.</li>
<li>Any general parsed entity reference which is not defined in the
internal subset and which occurs in the content is represented as a
<a href="qdomentityreference.html">QDomEntityReference</a>
node.</li>
<li>Any parsed entity reference which is not defined in the
internal subset and which occurs outside of the content is replaced
with an empty string.</li>
<li>Any unparsed entity reference is replaced with an empty
string.</li>
</ul>
<p><a href="qdomnode.html#prefix">QDomNode.prefix</a>() <a href="qstring.html#isNull">QString.isNull</a>() <a href="qstring.html#isEmpty">QString.isEmpty</a>()</p>
<p><b>Warning:</b> This function is not <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p>
<p><b>See also</b> <a href="qdomnode.html#namespaceURIx">QDomNode.namespaceURI</a>() and
<a href="qdomnode.html#localName">QDomNode.localName</a>().</p>


<h3 class="fn"><a name="setContent-2" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) QDomDocument.setContent (<i>self</i>, QString&#160;<i>text</i>, bool&#160;<i>namespaceProcessing</i>)</h3><p>This is an overloaded function.</p>
<p>This function reads the XML document from the string
<i>text</i>, returning true if the content was successfully parsed;
otherwise returns false. Since <i>text</i> is already a Unicode
string, no encoding detection is done.</p>


<h3 class="fn"><a name="setContent-3" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) QDomDocument.setContent (<i>self</i>, <a href="qiodevice.html">QIODevice</a>&#160;<i>dev</i>, bool&#160;<i>namespaceProcessing</i>)</h3><p>This is an overloaded function.</p>
<p>This function reads the XML document from the IO device
<i>dev</i>, returning true if the content was successfully parsed;
otherwise returns false.</p>


<h3 class="fn"><a name="setContent-4" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) QDomDocument.setContent (<i>self</i>, <a href="qxmlinputsource.html">QXmlInputSource</a>&#160;<i>source</i>, bool&#160;<i>namespaceProcessing</i>)</h3><p>This is an overloaded function.</p>
<p>This function reads the XML document from the <a href="qxmlinputsource.html">QXmlInputSource</a> <i>source</i>, returning
true if the content was successfully parsed; otherwise returns
false.</p>
<p>This function was introduced in Qt 4.5.</p>


<h3 class="fn"><a name="setContent-5" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) QDomDocument.setContent (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>buffer</i>)</h3><p>This is an overloaded function.</p>
<p>This function reads the XML document from the string
<i>text</i>, returning true if the content was successfully parsed;
otherwise returns false. Since <i>text</i> is already a Unicode
string, no encoding detection is performed.</p>
<p>No namespace processing is performed either.</p>


<h3 class="fn"><a name="setContent-6" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) QDomDocument.setContent (<i>self</i>, QString&#160;<i>text</i>)</h3><p>This is an overloaded function.</p>
<p>This function reads the XML document from the byte array
<i>buffer</i>, returning true if the content was successfully
parsed; otherwise returns false.</p>
<p>No namespace processing is performed.</p>


<h3 class="fn"><a name="setContent-7" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) QDomDocument.setContent (<i>self</i>, <a href="qiodevice.html">QIODevice</a>&#160;<i>dev</i>)</h3><p>This is an overloaded function.</p>
<p>This function reads the XML document from the IO device
<i>dev</i>, returning true if the content was successfully parsed;
otherwise returns false.</p>
<p>No namespace processing is performed.</p>


<h3 class="fn"><a name="setContent-8" />(bool, QString&#160;<i>errorMsg</i>, int&#160;<i>errorLine</i>, int&#160;<i>errorColumn</i>) QDomDocument.setContent (<i>self</i>, <a href="qxmlinputsource.html">QXmlInputSource</a>&#160;<i>source</i>, <a href="qxmlreader.html">QXmlReader</a>&#160;<i>reader</i>)</h3><p>This is an overloaded function.</p>
<p>This function reads the XML document from the <a href="qxmlinputsource.html">QXmlInputSource</a> <i>source</i> and parses
it with the <a href="qxmlreader.html">QXmlReader</a> <i>reader</i>,
returning true if the content was successfully parsed; otherwise
returns false.</p>
<p>This function doesn't change the features of the <i>reader</i>.
If you want to use certain features for parsing you can use this
function to set up the reader appropriately.</p>
<p><b>See also</b> <a href="qxmlsimplereader.html">QXmlSimpleReader</a>.</p>


<h3 class="fn"><a name="toByteArray" /><a href="qbytearray.html">QByteArray</a> QDomDocument.toByteArray (<i>self</i>, int&#160;<i>indent</i>&#160;=&#160;1)</h3><p>Converts the parsed document back to its textual representation
and returns a <a href="qbytearray.html">QByteArray</a> containing
the data encoded as UTF-8.</p>
<p>This function uses <i>indent</i> as the amount of space to
indent subelements.</p>
<p><b>See also</b> <a href="qdomdocument.html#toString">toString</a>().</p>


<h3 class="fn"><a name="toString" />QString QDomDocument.toString (<i>self</i>, int&#160;<i>indent</i>&#160;=&#160;1)</h3><p>Converts the parsed document back to its textual
representation.</p>
<p>This function uses <i>indent</i> as the amount of space to
indent subelements.</p>
<p>If <i>indent</i> is -1, no whitespace at all is added.</p>


<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.10.3 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.5</td></tr></table></div></address></body></html>