<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[issue with QXmlStreamWriter]]></title><description><![CDATA[<p dir="auto">I'm using QXmlStreamWriter to write to a QString object.</p>
<p dir="auto">The device I'm communicating with doesn't fully adhere to XML standards; the starting tag must be simply "&lt;XML&gt;". This wouldn't seem like a big deal, except that I can't use writeCharacters() because it escapes the angle brackets. I can use writeStartElement("XML") but this gives me "&lt;XML" (unclosed).</p>
<p dir="auto">I can use writeStartElement("XML&gt;") and this works, but strikes me as somewhat hokey.</p>
<p dir="auto">As an alternative, I suppose I could fully form the string, then edit out the stuff I can't have in the header.</p>
<p dir="auto">Any other opinions on this? Getting the format of the XML changed isn't an option.</p>
]]></description><link>https://forum.qt.io/topic/83876/issue-with-qxmlstreamwriter</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 08:04:23 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/83876.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Oct 2017 16:29:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to issue with QXmlStreamWriter on Wed, 04 Oct 2017 16:51:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hskoglund">@<bdi>hskoglund</bdi></a> that's probably a more correct way of doing it, but for simplicity's sake, I'm going to use Wieland's approach.</p>
]]></description><link>https://forum.qt.io/post/418815</link><guid isPermaLink="true">https://forum.qt.io/post/418815</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Wed, 04 Oct 2017 16:51:42 GMT</pubDate></item><item><title><![CDATA[Reply to issue with QXmlStreamWriter on Wed, 04 Oct 2017 16:49:09 GMT]]></title><description><![CDATA[<p dir="auto">Yeah, that's probably a better approach than mine, as it keeps the "&lt;&gt;" characters out of the stream handling. Thanks.</p>
]]></description><link>https://forum.qt.io/post/418814</link><guid isPermaLink="true">https://forum.qt.io/post/418814</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Wed, 04 Oct 2017 16:49:09 GMT</pubDate></item><item><title><![CDATA[Reply to issue with QXmlStreamWriter on Wed, 04 Oct 2017 16:47:22 GMT]]></title><description><![CDATA[<p dir="auto">Hi, I had more or less the same problem (receiving XML from Microsoft's IIS6 with way too much stuff), solved it by using XPath to strip away the junk. Perhaps you can use XPath as well to reformat your XML file, it's <a href="http://doc.qt.io/qt-5/qtxmlpatterns-index.html" target="_blank" rel="noopener noreferrer nofollow ugc">here</a></p>
]]></description><link>https://forum.qt.io/post/418813</link><guid isPermaLink="true">https://forum.qt.io/post/418813</guid><dc:creator><![CDATA[hskoglund]]></dc:creator><pubDate>Wed, 04 Oct 2017 16:47:22 GMT</pubDate></item><item><title><![CDATA[Reply to issue with QXmlStreamWriter on Wed, 04 Oct 2017 16:43:43 GMT]]></title><description><![CDATA[<p dir="auto">Hi! Little hackish, too, but seems to work:</p>
<pre><code>#include &lt;QApplication&gt;
#include &lt;QDebug&gt;
#include &lt;QXmlStreamWriter&gt;

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QString output;
    output += "&lt;XML&gt;";

    QXmlStreamWriter stream(&amp;output);
    stream.setAutoFormatting(true);
    stream.writeStartElement("bookmark");
    stream.writeAttribute("href", "http://qt-project.org/");
    stream.writeTextElement("title", "Qt Project");
    stream.writeEndElement(); // bookmark
    stream.writeEndDocument();

    qDebug() &lt;&lt; output;

    return 0;
}
</code></pre>
]]></description><link>https://forum.qt.io/post/418811</link><guid isPermaLink="true">https://forum.qt.io/post/418811</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 04 Oct 2017 16:43:43 GMT</pubDate></item></channel></rss>