<?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>QXmlStreamWriter 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="index.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">QXmlStreamWriter Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QXmlStreamWriter class provides an XML writer with a simple streaming API. <a href="#details">More...</a></p> <h3>Methods</h3><ul><li><div class="fn" /><b><a href="qxmlstreamwriter.html#QXmlStreamWriter">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#QXmlStreamWriter-2">__init__</a></b> (<i>self</i>, QIODevice <i>device</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#QXmlStreamWriter-3">__init__</a></b> (<i>self</i>, QByteArray <i>array</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#QXmlStreamWriter-4">__init__</a></b> (<i>self</i>, QString <i>string</i>)</li><li><div class="fn" />bool <b><a href="qxmlstreamwriter.html#autoFormatting">autoFormatting</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qxmlstreamwriter.html#autoFormattingIndent">autoFormattingIndent</a></b> (<i>self</i>)</li><li><div class="fn" />QTextCodec <b><a href="qxmlstreamwriter.html#codec">codec</a></b> (<i>self</i>)</li><li><div class="fn" />QIODevice <b><a href="qxmlstreamwriter.html#device">device</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qxmlstreamwriter.html#hasError">hasError</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#setAutoFormatting">setAutoFormatting</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#setAutoFormattingIndent">setAutoFormattingIndent</a></b> (<i>self</i>, int <i>spaces</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#setCodec">setCodec</a></b> (<i>self</i>, QTextCodec <i>codec</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#setCodec-2">setCodec</a></b> (<i>self</i>, str <i>codecName</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#setDevice">setDevice</a></b> (<i>self</i>, QIODevice <i>device</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeAttribute">writeAttribute</a></b> (<i>self</i>, QString <i>qualifiedName</i>, QString <i>value</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeAttribute-2">writeAttribute</a></b> (<i>self</i>, QString <i>namespaceUri</i>, QString <i>name</i>, QString <i>value</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeAttribute-3">writeAttribute</a></b> (<i>self</i>, QXmlStreamAttribute <i>attribute</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeAttributes">writeAttributes</a></b> (<i>self</i>, QXmlStreamAttributes <i>attributes</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeCDATA">writeCDATA</a></b> (<i>self</i>, QString <i>text</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeCharacters">writeCharacters</a></b> (<i>self</i>, QString <i>text</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeComment">writeComment</a></b> (<i>self</i>, QString <i>text</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeCurrentToken">writeCurrentToken</a></b> (<i>self</i>, QXmlStreamReader <i>reader</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeDefaultNamespace">writeDefaultNamespace</a></b> (<i>self</i>, QString <i>namespaceUri</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeDTD">writeDTD</a></b> (<i>self</i>, QString <i>dtd</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeEmptyElement">writeEmptyElement</a></b> (<i>self</i>, QString <i>qualifiedName</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeEmptyElement-2">writeEmptyElement</a></b> (<i>self</i>, QString <i>namespaceUri</i>, QString <i>name</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeEndDocument">writeEndDocument</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeEndElement">writeEndElement</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeEntityReference">writeEntityReference</a></b> (<i>self</i>, QString <i>name</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeNamespace">writeNamespace</a></b> (<i>self</i>, QString <i>namespaceUri</i>, QString <i>prefix</i> = QString())</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeProcessingInstruction">writeProcessingInstruction</a></b> (<i>self</i>, QString <i>target</i>, QString <i>data</i> = QString())</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeStartDocument">writeStartDocument</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeStartDocument-2">writeStartDocument</a></b> (<i>self</i>, QString <i>version</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeStartDocument-3">writeStartDocument</a></b> (<i>self</i>, QString <i>version</i>, bool <i>standalone</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeStartElement">writeStartElement</a></b> (<i>self</i>, QString <i>qualifiedName</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeStartElement-2">writeStartElement</a></b> (<i>self</i>, QString <i>namespaceUri</i>, QString <i>name</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeTextElement">writeTextElement</a></b> (<i>self</i>, QString <i>qualifiedName</i>, QString <i>text</i>)</li><li><div class="fn" /><b><a href="qxmlstreamwriter.html#writeTextElement-2">writeTextElement</a></b> (<i>self</i>, QString <i>namespaceUri</i>, QString <i>name</i>, QString <i>text</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QXmlStreamWriter class provides an XML writer with a simple streaming API.</p> <p>QXmlStreamWriter is the counterpart to <a href="qxmlstreamreader.html">QXmlStreamReader</a> for writing XML. Like its related class, it operates on a <a href="qiodevice.html">QIODevice</a> specified with <a href="qxmlstreamwriter.html#setDevice">setDevice</a>(). The API is simple and straightforward: for every XML token or event you want to write, the writer provides a specialized function.</p> <p>You start a document with <a href="qxmlstreamwriter.html#writeStartDocument">writeStartDocument</a>() and end it with <a href="qxmlstreamwriter.html#writeEndDocument">writeEndDocument</a>(). This will implicitly close all remaining open tags.</p> <p>Element tags are opened with <a href="qxmlstreamwriter.html#writeStartElement">writeStartElement</a>() followed by <a href="qxmlstreamwriter.html#writeAttribute">writeAttribute</a>() or <a href="qxmlstreamwriter.html#writeAttributes">writeAttributes</a>(), element content, and then <a href="qxmlstreamwriter.html#writeEndElement">writeEndElement</a>(). A shorter form <a href="qxmlstreamwriter.html#writeEmptyElement">writeEmptyElement</a>() can be used to write empty elements, followed by <a href="qxmlstreamwriter.html#writeAttributes">writeAttributes</a>().</p> <p>Element content consists of either characters, entity references or nested elements. It is written with <a href="qxmlstreamwriter.html#writeCharacters">writeCharacters</a>(), which also takes care of escaping all forbidden characters and character sequences, <a href="qxmlstreamwriter.html#writeEntityReference">writeEntityReference</a>(), or subsequent calls to <a href="qxmlstreamwriter.html#writeStartElement">writeStartElement</a>(). A convenience method <a href="qxmlstreamwriter.html#writeTextElement">writeTextElement</a>() can be used for writing terminal elements that contain nothing but text.</p> <p>The following abridged code snippet shows the basic use of the class to write formatted XML with indentation:</p> <pre class="cpp"> <span class="type">QXmlStreamWriter</span> stream(<span class="operator">&</span>output); stream<span class="operator">.</span>setAutoFormatting(<span class="keyword">true</span>); stream<span class="operator">.</span>writeStartDocument(); ... stream<span class="operator">.</span>writeStartElement(<span class="string">"bookmark"</span>); stream<span class="operator">.</span>writeAttribute(<span class="string">"href"</span><span class="operator">,</span> <span class="string">"http://qt.nokia.com/"</span>); stream<span class="operator">.</span>writeTextElement(<span class="string">"title"</span><span class="operator">,</span> <span class="string">"Qt Home"</span>); stream<span class="operator">.</span>writeEndElement(); <span class="comment">// bookmark</span> ... stream<span class="operator">.</span>writeEndDocument(); </pre> <p>QXmlStreamWriter takes care of prefixing namespaces, all you have to do is specify the <tt>namespaceUri</tt> when writing elements or attributes. If you must conform to certain prefixes, you can force the writer to use them by declaring the namespaces manually with either <a href="qxmlstreamwriter.html#writeNamespace">writeNamespace</a>() or <a href="qxmlstreamwriter.html#writeDefaultNamespace">writeDefaultNamespace</a>(). Alternatively, you can bypass the stream writer's namespace support and use overloaded methods that take a qualified name instead. The namespace <i>http://www.w3.org/XML/1998/namespace</i> is implicit and mapped to the prefix <i>xml</i>.</p> <p>The stream writer can automatically format the generated XML data by adding line-breaks and indentation to empty sections between elements, making the XML data more readable for humans and easier to work with for most source code management systems. The feature can be turned on with the <a href="qxmlstreamwriter.html#autoFormatting-prop">autoFormatting</a> property, and customized with the <a href="qxmlstreamwriter.html#autoFormattingIndent-prop">autoFormattingIndent</a> property.</p> <p>Other functions are <a href="qxmlstreamwriter.html#writeCDATA">writeCDATA</a>(), <a href="qxmlstreamwriter.html#writeComment">writeComment</a>(), <a href="qxmlstreamwriter.html#writeProcessingInstruction">writeProcessingInstruction</a>(), and <a href="qxmlstreamwriter.html#writeDTD">writeDTD</a>(). Chaining of XML streams is supported with <a href="qxmlstreamwriter.html#writeCurrentToken">writeCurrentToken</a>().</p> <p>By default, QXmlStreamWriter encodes XML in UTF-8. Different encodings can be enforced using <a href="qxmlstreamwriter.html#setCodec">setCodec</a>().</p> <p>If an error occurs while writing to the underlying device, <a href="qxmlstreamwriter.html#hasError">hasError</a>() starts returning true and subsequent writes are ignored.</p> <p>The <a href="xml-streambookmarks.html">QXmlStream Bookmarks Example</a> illustrates how to use a stream writer to write an XML bookmark file (XBEL) that was previously read in by a <a href="qxmlstreamreader.html">QXmlStreamReader</a>.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QXmlStreamWriter" />QXmlStreamWriter.__init__ (<i>self</i>)</h3><p>Constructs a stream writer.</p> <p><b>See also</b> <a href="qxmlstreamwriter.html#setDevice">setDevice</a>().</p> <h3 class="fn"><a name="QXmlStreamWriter-2" />QXmlStreamWriter.__init__ (<i>self</i>, <a href="qiodevice.html">QIODevice</a> <i>device</i>)</h3><p>Constructs a stream writer that writes into <i>device</i>;</p> <h3 class="fn"><a name="QXmlStreamWriter-3" />QXmlStreamWriter.__init__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a> <i>array</i>)</h3><p>Constructs a stream writer that writes into <i>array</i>. This is the same as creating an xml writer that operates on a <a href="qbuffer.html">QBuffer</a> device which in turn operates on <i>array</i>.</p> <h3 class="fn"><a name="QXmlStreamWriter-4" />QXmlStreamWriter.__init__ (<i>self</i>, QString <i>string</i>)</h3><p>Constructs a stream writer that writes into <i>string</i>.</p> <h3 class="fn"><a name="autoFormatting" />bool QXmlStreamWriter.autoFormatting (<i>self</i>)</h3><h3 class="fn"><a name="autoFormattingIndent" />int QXmlStreamWriter.autoFormattingIndent (<i>self</i>)</h3><h3 class="fn"><a name="codec" /><a href="qtextcodec.html">QTextCodec</a> QXmlStreamWriter.codec (<i>self</i>)</h3><p>Returns the codec that is currently assigned to the stream.</p> <p><b>See also</b> <a href="qxmlstreamwriter.html#setCodec">setCodec</a>().</p> <h3 class="fn"><a name="device" /><a href="qiodevice.html">QIODevice</a> QXmlStreamWriter.device (<i>self</i>)</h3><p>Returns the current device associated with the <a href="qxmlstreamwriter.html">QXmlStreamWriter</a>, or 0 if no device has been assigned.</p> <p><b>See also</b> <a href="qxmlstreamwriter.html#setDevice">setDevice</a>().</p> <h3 class="fn"><a name="hasError" />bool QXmlStreamWriter.hasError (<i>self</i>)</h3><p>Returns true if the stream failed to write to the underlying device; otherwise returns false.</p> <p>The error status is never reset. Writes happening after the error occurred are ignored, even if the error condition is cleared.</p> <p>This function was introduced in Qt 4.8.</p> <h3 class="fn"><a name="setAutoFormatting" />QXmlStreamWriter.setAutoFormatting (<i>self</i>, bool)</h3><h3 class="fn"><a name="setAutoFormattingIndent" />QXmlStreamWriter.setAutoFormattingIndent (<i>self</i>, int <i>spaces</i>)</h3><h3 class="fn"><a name="setCodec" />QXmlStreamWriter.setCodec (<i>self</i>, <a href="qtextcodec.html">QTextCodec</a> <i>codec</i>)</h3><p>Sets the codec for this stream to <i>codec</i>. The codec is used for encoding any data that is written. By default, <a href="qxmlstreamwriter.html">QXmlStreamWriter</a> uses UTF-8.</p> <p>The encoding information is stored in the initial xml tag which gets written when you call <a href="qxmlstreamwriter.html#writeStartDocument">writeStartDocument</a>(). Call this function before calling <a href="qxmlstreamwriter.html#writeStartDocument">writeStartDocument</a>().</p> <p><b>See also</b> <a href="qxmlstreamwriter.html#codec">codec</a>().</p> <h3 class="fn"><a name="setCodec-2" />QXmlStreamWriter.setCodec (<i>self</i>, str <i>codecName</i>)</h3><p>Sets the codec for this stream to the <a href="qtextcodec.html">QTextCodec</a> for the encoding specified by <i>codecName</i>. Common values for <tt>codecName</tt> include "ISO 8859-1", "UTF-8", and "UTF-16". If the encoding isn't recognized, nothing happens.</p> <p><b>See also</b> <a href="qtextcodec.html#codecForName">QTextCodec.codecForName</a>().</p> <h3 class="fn"><a name="setDevice" />QXmlStreamWriter.setDevice (<i>self</i>, <a href="qiodevice.html">QIODevice</a> <i>device</i>)</h3><p>Sets the current device to <i>device</i>. If you want the stream to write into a <a href="qbytearray.html">QByteArray</a>, you can create a <a href="qbuffer.html">QBuffer</a> device.</p> <p><b>See also</b> <a href="qxmlstreamwriter.html#device">device</a>().</p> <h3 class="fn"><a name="writeAttribute" />QXmlStreamWriter.writeAttribute (<i>self</i>, QString <i>qualifiedName</i>, QString <i>value</i>)</h3><p>Writes an attribute with <i>name</i> and <i>value</i>, prefixed for the specified <i>namespaceUri</i>. If the namespace has not been declared yet, <a href="qxmlstreamwriter.html">QXmlStreamWriter</a> will generate a namespace declaration for it.</p> <p>This function can only be called after <a href="qxmlstreamwriter.html#writeStartElement">writeStartElement</a>() before any content is written, or after <a href="qxmlstreamwriter.html#writeEmptyElement">writeEmptyElement</a>().</p> <h3 class="fn"><a name="writeAttribute-2" />QXmlStreamWriter.writeAttribute (<i>self</i>, QString <i>namespaceUri</i>, QString <i>name</i>, QString <i>value</i>)</h3><p>This is an overloaded function.</p> <p>Writes an attribute with <i>qualifiedName</i> and <i>value</i>.</p> <p>This function can only be called after <a href="qxmlstreamwriter.html#writeStartElement">writeStartElement</a>() before any content is written, or after <a href="qxmlstreamwriter.html#writeEmptyElement">writeEmptyElement</a>().</p> <h3 class="fn"><a name="writeAttribute-3" />QXmlStreamWriter.writeAttribute (<i>self</i>, <a href="qxmlstreamattribute.html">QXmlStreamAttribute</a> <i>attribute</i>)</h3><p>This is an overloaded function.</p> <p>Writes the <i>attribute</i>.</p> <p>This function can only be called after <a href="qxmlstreamwriter.html#writeStartElement">writeStartElement</a>() before any content is written, or after <a href="qxmlstreamwriter.html#writeEmptyElement">writeEmptyElement</a>().</p> <h3 class="fn"><a name="writeAttributes" />QXmlStreamWriter.writeAttributes (<i>self</i>, <a href="qxmlstreamattributes.html">QXmlStreamAttributes</a> <i>attributes</i>)</h3><p>Writes the attribute vector <i>attributes</i>. If a namespace referenced in an attribute not been declared yet, <a href="qxmlstreamwriter.html">QXmlStreamWriter</a> will generate a namespace declaration for it.</p> <p>This function can only be called after <a href="qxmlstreamwriter.html#writeStartElement">writeStartElement</a>() before any content is written, or after <a href="qxmlstreamwriter.html#writeEmptyElement">writeEmptyElement</a>().</p> <p><b>See also</b> <a href="qxmlstreamwriter.html#writeAttribute">writeAttribute</a>() and <a href="qxmlstreamwriter.html#writeNamespace">writeNamespace</a>().</p> <h3 class="fn"><a name="writeCDATA" />QXmlStreamWriter.writeCDATA (<i>self</i>, QString <i>text</i>)</h3><p>Writes <i>text</i> as CDATA section. If <i>text</i> contains the forbidden character sequence "]]>", it is split into different CDATA sections.</p> <p>This function mainly exists for completeness. Normally you should not need use it, because <a href="qxmlstreamwriter.html#writeCharacters">writeCharacters</a>() automatically escapes all non-content characters.</p> <h3 class="fn"><a name="writeCharacters" />QXmlStreamWriter.writeCharacters (<i>self</i>, QString <i>text</i>)</h3><p>Writes <i>text</i>. The characters "<", "&", and """ are escaped as entity references "&lt;", "&amp;, and "&quot;". To avoid the forbidden sequence "]]>", ">" is also escaped as "&gt;".</p> <p><b>See also</b> <a href="qxmlstreamwriter.html#writeEntityReference">writeEntityReference</a>().</p> <h3 class="fn"><a name="writeComment" />QXmlStreamWriter.writeComment (<i>self</i>, QString <i>text</i>)</h3><p>Writes <i>text</i> as XML comment, where <i>text</i> must not contain the forbidden sequence "--" or end with "-". Note that XML does not provide any way to escape "-" in a comment.</p> <h3 class="fn"><a name="writeCurrentToken" />QXmlStreamWriter.writeCurrentToken (<i>self</i>, <a href="qxmlstreamreader.html">QXmlStreamReader</a> <i>reader</i>)</h3><p>Writes the current state of the <i>reader</i>. All possible valid states are supported.</p> <p>The purpose of this function is to support chained processing of XML data.</p> <p><b>See also</b> <a href="qxmlstreamreader.html#tokenType">QXmlStreamReader.tokenType</a>().</p> <h3 class="fn"><a name="writeDefaultNamespace" />QXmlStreamWriter.writeDefaultNamespace (<i>self</i>, QString <i>namespaceUri</i>)</h3><p>Writes a default namespace declaration for <i>namespaceUri</i>.</p> <p>If <a href="qxmlstreamwriter.html#writeStartElement">writeStartElement</a>() or <a href="qxmlstreamwriter.html#writeEmptyElement">writeEmptyElement</a>() was called, the declaration applies to the current element; otherwise it applies to the next child element.</p> <p>Note that the namespaces <i>http://www.w3.org/XML/1998/namespace</i> (bound to <i>xmlns</i>) and <i>http://www.w3.org/2000/xmlns/</i> (bound to <i>xml</i>) by definition cannot be declared as default.</p> <h3 class="fn"><a name="writeDTD" />QXmlStreamWriter.writeDTD (<i>self</i>, QString <i>dtd</i>)</h3><p>Writes a DTD section. The <i>dtd</i> represents the entire doctypedecl production from the XML 1.0 specification.</p> <h3 class="fn"><a name="writeEmptyElement" />QXmlStreamWriter.writeEmptyElement (<i>self</i>, QString <i>qualifiedName</i>)</h3><p>Writes an empty element with <i>name</i>, prefixed for the specified <i>namespaceUri</i>. If the namespace has not been declared, <a href="qxmlstreamwriter.html">QXmlStreamWriter</a> will generate a namespace declaration for it. Subsequent calls to <a href="qxmlstreamwriter.html#writeAttribute">writeAttribute</a>() will add attributes to this element.</p> <p><b>See also</b> <a href="qxmlstreamwriter.html#writeNamespace">writeNamespace</a>().</p> <h3 class="fn"><a name="writeEmptyElement-2" />QXmlStreamWriter.writeEmptyElement (<i>self</i>, QString <i>namespaceUri</i>, QString <i>name</i>)</h3><p>This is an overloaded function.</p> <p>Writes an empty element with qualified name <i>qualifiedName</i>. Subsequent calls to <a href="qxmlstreamwriter.html#writeAttribute">writeAttribute</a>() will add attributes to this element.</p> <h3 class="fn"><a name="writeEndDocument" />QXmlStreamWriter.writeEndDocument (<i>self</i>)</h3><p>Closes all remaining open start elements and writes a newline.</p> <p><b>See also</b> <a href="qxmlstreamwriter.html#writeStartDocument">writeStartDocument</a>().</p> <h3 class="fn"><a name="writeEndElement" />QXmlStreamWriter.writeEndElement (<i>self</i>)</h3><p>Closes the previous start element.</p> <p><b>See also</b> <a href="qxmlstreamwriter.html#writeStartElement">writeStartElement</a>().</p> <h3 class="fn"><a name="writeEntityReference" />QXmlStreamWriter.writeEntityReference (<i>self</i>, QString <i>name</i>)</h3><p>Writes the entity reference <i>name</i> to the stream, as "&<i>name</i>;".</p> <h3 class="fn"><a name="writeNamespace" />QXmlStreamWriter.writeNamespace (<i>self</i>, QString <i>namespaceUri</i>, QString <i>prefix</i> = QString())</h3><p>Writes a namespace declaration for <i>namespaceUri</i> with <i>prefix</i>. If <i>prefix</i> is empty, <a href="qxmlstreamwriter.html">QXmlStreamWriter</a> assigns a unique prefix consisting of the letter 'n' followed by a number.</p> <p>If <a href="qxmlstreamwriter.html#writeStartElement">writeStartElement</a>() or <a href="qxmlstreamwriter.html#writeEmptyElement">writeEmptyElement</a>() was called, the declaration applies to the current element; otherwise it applies to the next child element.</p> <p>Note that the prefix <i>xml</i> is both predefined and reserved for <i>http://www.w3.org/XML/1998/namespace</i>, which in turn cannot be bound to any other prefix. The prefix <i>xmlns</i> and its URI <i>http://www.w3.org/2000/xmlns/</i> are used for the namespace mechanism itself and thus completely forbidden in declarations.</p> <h3 class="fn"><a name="writeProcessingInstruction" />QXmlStreamWriter.writeProcessingInstruction (<i>self</i>, QString <i>target</i>, QString <i>data</i> = QString())</h3><p>Writes an XML processing instruction with <i>target</i> and <i>data</i>, where <i>data</i> must not contain the sequence "?>".</p> <h3 class="fn"><a name="writeStartDocument" />QXmlStreamWriter.writeStartDocument (<i>self</i>)</h3><p>Writes a document start with the XML version number <i>version</i>.</p> <p><b>See also</b> <a href="qxmlstreamwriter.html#writeEndDocument">writeEndDocument</a>().</p> <h3 class="fn"><a name="writeStartDocument-2" />QXmlStreamWriter.writeStartDocument (<i>self</i>, QString <i>version</i>)</h3><p>Writes a document start with the XML version number <i>version</i> and a standalone attribute <i>standalone</i>.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also</b> <a href="qxmlstreamwriter.html#writeEndDocument">writeEndDocument</a>().</p> <h3 class="fn"><a name="writeStartDocument-3" />QXmlStreamWriter.writeStartDocument (<i>self</i>, QString <i>version</i>, bool <i>standalone</i>)</h3><p>This is an overloaded function.</p> <p>Writes a document start with XML version number "1.0". This also writes the encoding information.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also</b> <a href="qxmlstreamwriter.html#writeEndDocument">writeEndDocument</a>() and <a href="qxmlstreamwriter.html#setCodec">setCodec</a>().</p> <h3 class="fn"><a name="writeStartElement" />QXmlStreamWriter.writeStartElement (<i>self</i>, QString <i>qualifiedName</i>)</h3><p>Writes a start element with <i>name</i>, prefixed for the specified <i>namespaceUri</i>. If the namespace has not been declared yet, <a href="qxmlstreamwriter.html">QXmlStreamWriter</a> will generate a namespace declaration for it. Subsequent calls to <a href="qxmlstreamwriter.html#writeAttribute">writeAttribute</a>() will add attributes to this element.</p> <p><b>See also</b> <a href="qxmlstreamwriter.html#writeNamespace">writeNamespace</a>(), <a href="qxmlstreamwriter.html#writeEndElement">writeEndElement</a>(), and <a href="qxmlstreamwriter.html#writeEmptyElement">writeEmptyElement</a>().</p> <h3 class="fn"><a name="writeStartElement-2" />QXmlStreamWriter.writeStartElement (<i>self</i>, QString <i>namespaceUri</i>, QString <i>name</i>)</h3><p>This is an overloaded function.</p> <p>Writes a start element with <i>qualifiedName</i>. Subsequent calls to <a href="qxmlstreamwriter.html#writeAttribute">writeAttribute</a>() will add attributes to this element.</p> <p><b>See also</b> <a href="qxmlstreamwriter.html#writeEndElement">writeEndElement</a>() and <a href="qxmlstreamwriter.html#writeEmptyElement">writeEmptyElement</a>().</p> <h3 class="fn"><a name="writeTextElement" />QXmlStreamWriter.writeTextElement (<i>self</i>, QString <i>qualifiedName</i>, QString <i>text</i>)</h3><p>Writes a text element with <i>name</i>, prefixed for the specified <i>namespaceUri</i>, and <i>text</i>. If the namespace has not been declared, <a href="qxmlstreamwriter.html">QXmlStreamWriter</a> will generate a namespace declaration for it.</p> <p>This is a convenience function equivalent to:</p> <pre class="cpp"> <a href="qxmlstreamwriter.html#writeStartElement">writeStartElement</a>(namespaceUri<span class="operator">,</span> name); <a href="qxmlstreamwriter.html#writeCharacters">writeCharacters</a>(text); <a href="qxmlstreamwriter.html#writeEndElement">writeEndElement</a>(); </pre> <h3 class="fn"><a name="writeTextElement-2" />QXmlStreamWriter.writeTextElement (<i>self</i>, QString <i>namespaceUri</i>, QString <i>name</i>, QString <i>text</i>)</h3><p>This is an overloaded function.</p> <p>Writes a text element with <i>qualifiedName</i> and <i>text</i>.</p> <p>This is a convenience function equivalent to:</p> <pre class="cpp"> <a href="qxmlstreamwriter.html#writeStartElement">writeStartElement</a>(qualifiedName); <a href="qxmlstreamwriter.html#writeCharacters">writeCharacters</a>(text); <a href="qxmlstreamwriter.html#writeEndElement">writeEndElement</a>(); </pre> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>