1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
|
<?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">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <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 <i>name</i>)</li><li><div class="fn" /><b><a href="qdomdocument.html#QDomDocument-3">__init__</a></b> (<i>self</i>, QDomDocumentType <i>doctype</i>)</li><li><div class="fn" /><b><a href="qdomdocument.html#QDomDocument-4">__init__</a></b> (<i>self</i>, QDomDocument <i>x</i>)</li><li><div class="fn" />QDomAttr <b><a href="qdomdocument.html#createAttribute">createAttribute</a></b> (<i>self</i>, QString <i>name</i>)</li><li><div class="fn" />QDomAttr <b><a href="qdomdocument.html#createAttributeNS">createAttributeNS</a></b> (<i>self</i>, QString <i>nsURI</i>, QString <i>qName</i>)</li><li><div class="fn" />QDomCDATASection <b><a href="qdomdocument.html#createCDATASection">createCDATASection</a></b> (<i>self</i>, QString <i>data</i>)</li><li><div class="fn" />QDomComment <b><a href="qdomdocument.html#createComment">createComment</a></b> (<i>self</i>, QString <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 <i>tagName</i>)</li><li><div class="fn" />QDomElement <b><a href="qdomdocument.html#createElementNS">createElementNS</a></b> (<i>self</i>, QString <i>nsURI</i>, QString <i>qName</i>)</li><li><div class="fn" />QDomEntityReference <b><a href="qdomdocument.html#createEntityReference">createEntityReference</a></b> (<i>self</i>, QString <i>name</i>)</li><li><div class="fn" />QDomProcessingInstruction <b><a href="qdomdocument.html#createProcessingInstruction">createProcessingInstruction</a></b> (<i>self</i>, QString <i>target</i>, QString <i>data</i>)</li><li><div class="fn" />QDomText <b><a href="qdomdocument.html#createTextNode">createTextNode</a></b> (<i>self</i>, QString <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 <i>elementId</i>)</li><li><div class="fn" />QDomNodeList <b><a href="qdomdocument.html#elementsByTagName">elementsByTagName</a></b> (<i>self</i>, QString <i>tagname</i>)</li><li><div class="fn" />QDomNodeList <b><a href="qdomdocument.html#elementsByTagNameNS">elementsByTagNameNS</a></b> (<i>self</i>, QString <i>nsURI</i>, QString <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 <i>importedNode</i>, bool <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 <i>errorMsg</i>, int <i>errorLine</i>, int <i>errorColumn</i>) <b><a href="qdomdocument.html#setContent">setContent</a></b> (<i>self</i>, QByteArray <i>text</i>, bool <i>namespaceProcessing</i>)</li><li><div class="fn" />(bool, QString <i>errorMsg</i>, int <i>errorLine</i>, int <i>errorColumn</i>) <b><a href="qdomdocument.html#setContent-2">setContent</a></b> (<i>self</i>, QString <i>text</i>, bool <i>namespaceProcessing</i>)</li><li><div class="fn" />(bool, QString <i>errorMsg</i>, int <i>errorLine</i>, int <i>errorColumn</i>) <b><a href="qdomdocument.html#setContent-3">setContent</a></b> (<i>self</i>, QIODevice <i>dev</i>, bool <i>namespaceProcessing</i>)</li><li><div class="fn" />(bool, QString <i>errorMsg</i>, int <i>errorLine</i>, int <i>errorColumn</i>) <b><a href="qdomdocument.html#setContent-4">setContent</a></b> (<i>self</i>, QByteArray <i>text</i>)</li><li><div class="fn" />(bool, QString <i>errorMsg</i>, int <i>errorLine</i>, int <i>errorColumn</i>) <b><a href="qdomdocument.html#setContent-5">setContent</a></b> (<i>self</i>, QString <i>text</i>)</li><li><div class="fn" />(bool, QString <i>errorMsg</i>, int <i>errorLine</i>, int <i>errorColumn</i>) <b><a href="qdomdocument.html#setContent-6">setContent</a></b> (<i>self</i>, QIODevice <i>dev</i>)</li><li><div class="fn" />(bool, QString <i>errorMsg</i>, int <i>errorLine</i>, int <i>errorColumn</i>) <b><a href="qdomdocument.html#setContent-7">setContent</a></b> (<i>self</i>, QXmlInputSource <i>source</i>, QXmlReader <i>reader</i>)</li><li><div class="fn" />QByteArray <b><a href="qdomdocument.html#toByteArray">toByteArray</a></b> (<i>self</i>, int = 1)</li><li><div class="fn" />QString <b><a href="qdomdocument.html#toString">toString</a></b> (<i>self</i>, int = 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>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>
QDomDocument doc("mydocument");
QFile file("mydocument.xml");
if (!file.open(QIODevice.ReadOnly))
return;
if (!doc.setContent(&file)) {
file.close();
return;
}
file.close();
// print out the element names of all elements that are direct children
// of the outermost element.
QDomElement docElem = doc.documentElement();
QDomNode n = docElem.firstChild();
while(!n.isNull()) {
QDomElement e = n.toElement(); // try to convert the node to an element.
if(!e.isNull()) {
cout << e.tagName() << endl; // the node really is an element.
}
n = n.nextSibling();
}
// Here we append a new element to the end of the document
QDomElement elem = doc.createElement("img");
elem.setAttribute("src", "myimage.png");
docElem.appendChild(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>
QDomDocument doc("MyML");
QDomElement root = doc.createElement("MyML");
doc.appendChild(root);
QDomElement tag = doc.createElement("Greeting");
root.appendChild(tag);
QDomText t = doc.createTextNode("Hello World");
tag.appendChild(t);
QString xml = doc.toString();
</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>, <a href="qstring.html">QString</a> <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> <i>doctype</i>)</h3><p>Creates a document with the document type <i>doctype</i>.</p>
<p>See also <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> <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>, <a href="qstring.html">QString</a> <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>See also <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>, <a href="qstring.html">QString</a> <i>nsURI</i>, <a href="qstring.html">QString</a> <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>See also <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>, <a href="qstring.html">QString</a> <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>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>().</p>
<h3 class="fn"><a name="createComment" /><a href="qdomcomment.html">QDomComment</a> QDomDocument.createComment (<i>self</i>, <a href="qstring.html">QString</a> <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>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>().</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>, <a href="qstring.html">QString</a> <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>See also <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>, <a href="qstring.html">QString</a> <i>nsURI</i>, <a href="qstring.html">QString</a> <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.</p>
<p>See also <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>, <a href="qstring.html">QString</a> <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>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>().</p>
<h3 class="fn"><a name="createProcessingInstruction" /><a href="qdomprocessinginstruction.html">QDomProcessingInstruction</a> QDomDocument.createProcessingInstruction (<i>self</i>, <a href="qstring.html">QString</a> <i>target</i>, <a href="qstring.html">QString</a> <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>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>().</p>
<h3 class="fn"><a name="createTextNode" /><a href="qdomtext.html">QDomText</a> QDomDocument.createTextNode (<i>self</i>, <a href="qstring.html">QString</a> <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>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>().</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>, <a href="qstring.html">QString</a> <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>, <a href="qstring.html">QString</a> <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>See also <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>, <a href="qstring.html">QString</a> <i>nsURI</i>, <a href="qstring.html">QString</a> <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>See also <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> <i>importedNode</i>, bool <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 descendents 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 align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#A2C511" valign="top">
<th>Node Type</th>
<th>Behavior</th>
</tr>
<tr bgcolor="#F0F0F0" 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 bgcolor="#E0E0E0" valign="top">
<td><a href="qdomdocument.html">QDomDocument</a></td>
<td>Document nodes cannot be imported.</td>
</tr>
<tr bgcolor="#F0F0F0" 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 bgcolor="#E0E0E0" valign="top">
<td><a href="qdomdocumenttype.html">QDomDocumentType</a></td>
<td>Document type nodes cannot be imported.</td>
</tr>
<tr bgcolor="#F0F0F0" 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 bgcolor="#E0E0E0" 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 bgcolor="#F0F0F0" valign="top">
<td><a href="qdomentityreference.html">QDomEntityReference</a></td>
<td>Descendents of entity reference nodes are never imported: <i>deep</i> has no effect.</td>
</tr>
<tr bgcolor="#E0E0E0" 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 bgcolor="#F0F0F0" 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 bgcolor="#E0E0E0" valign="top">
<td><a href="qdomtext.html">QDomText</a></td>
<td>The text is copied to the new node.</td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td><a href="qdomcdatasection.html">QDomCDATASection</a></td>
<td>The text is copied to the new node.</td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td><a href="qdomcomment.html">QDomComment</a></td>
<td>The text is copied to the new node.</td>
</tr>
</table>
<br />
<br />
<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>See also <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, <a href="qstring.html">QString</a> <i>errorMsg</i>, int <i>errorLine</i>, int <i>errorColumn</i>) QDomDocument.setContent (<i>self</i>, <a href="qbytearray.html">QByteArray</a> <i>text</i>, bool <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, the function returns false; otherwise it returns true. If a parse error occurs and <i>errorMsg</i>, <i>errorLine</i> and <i>errorColumn</i> are not 0, the error message is placed in <tt>*</tt><i>errorMsg</i>, the line number <tt>*</tt><i>errorLine</i> and the column number in <tt>*</tt><i>errorColumn</i>.</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>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#namespaceURI">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 occuring 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 occuring 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>See also <a href="qdomnode.html#namespaceURI">QDomNode.namespaceURI</a>() and <a href="qdomnode.html#localName">QDomNode.localName</a>().</p>
<h3 class="fn"><a name="setContent-2" />(bool, <a href="qstring.html">QString</a> <i>errorMsg</i>, int <i>errorLine</i>, int <i>errorColumn</i>) QDomDocument.setContent (<i>self</i>, <a href="qstring.html">QString</a> <i>text</i>, bool <i>namespaceProcessing</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>This function reads the XML document from the string <i>text</i>. Since <i>text</i> is already a Unicode string, no encoding detection is done.</p>
<h3 class="fn"><a name="setContent-3" />(bool, <a href="qstring.html">QString</a> <i>errorMsg</i>, int <i>errorLine</i>, int <i>errorColumn</i>) QDomDocument.setContent (<i>self</i>, <a href="qiodevice.html">QIODevice</a> <i>dev</i>, bool <i>namespaceProcessing</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>This function reads the XML document from the IO device <i>dev</i>.</p>
<h3 class="fn"><a name="setContent-4" />(bool, <a href="qstring.html">QString</a> <i>errorMsg</i>, int <i>errorLine</i>, int <i>errorColumn</i>) QDomDocument.setContent (<i>self</i>, <a href="qbytearray.html">QByteArray</a> <i>text</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>This function reads the XML document from the string <i>text</i>. 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-5" />(bool, <a href="qstring.html">QString</a> <i>errorMsg</i>, int <i>errorLine</i>, int <i>errorColumn</i>) QDomDocument.setContent (<i>self</i>, <a href="qstring.html">QString</a> <i>text</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>This function reads the XML document from the byte array <i>buffer</i>.</p>
<p>No namespace processing is performed.</p>
<h3 class="fn"><a name="setContent-6" />(bool, <a href="qstring.html">QString</a> <i>errorMsg</i>, int <i>errorLine</i>, int <i>errorColumn</i>) QDomDocument.setContent (<i>self</i>, <a href="qiodevice.html">QIODevice</a> <i>dev</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>This function reads the XML document from the IO device <i>dev</i>.</p>
<p>No namespace processing is performed.</p>
<h3 class="fn"><a name="setContent-7" />(bool, <a href="qstring.html">QString</a> <i>errorMsg</i>, int <i>errorLine</i>, int <i>errorColumn</i>) QDomDocument.setContent (<i>self</i>, <a href="qxmlinputsource.html">QXmlInputSource</a> <i>source</i>, <a href="qxmlreader.html">QXmlReader</a> <i>reader</i>)</h3><p>This is an overloaded member function, provided for convenience.</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>.</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>See also <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 = 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>See also <a href="qdomdocument.html#toString">toString</a>().</p>
<h3 class="fn"><a name="toString" /><a href="qstring.html">QString</a> QDomDocument.toString (<i>self</i>, int = 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>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt 4.0.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.trolltech.com">Trolltech AS</a> 2006</td><td align="right" width="25%">Qt 4.1.4</td></tr></table></div></address></body></html>
|