title: How to auto-format and indent XML from a string?
body: <p>I'm taking my first steps with Qt4.8.6 under Debian 7 at the moment and I really like it! But now I need a little help with this issue:</p>
  
  <p>My application connects to a server and triggers a data request. XML data is then sent back in one or multiple TCP packets to my application, where it is assembled into a complete "message", which is nothing else then a well-formed XML document containing the requested data.</p>
  
  <p>Receiving the data works flawlessly, but now I want to display the received XML data in a nicely formed way for debug purposes etc. The problem: I do have the XML data in a simple QString and I don't want to start beautifying it by hand with my own routines. I've seen that there is a XmlStreamWriter that offers auto formatting. That sounds nice! But how can I "feed" it with my XML data and let it output the formatted data into another QString?</p>
  
  <pre><code>void MainWindow::displayMessage(QString message)
  {
      QString formattedOutput;
  
      QXmlStreamReader xmlreader(message);
  
      QXmlStreamWriter xmlwriter(&amp;formattedOutput);
      xmlwriter.setAutoFormatting(true);
  
      ResponseTextEdit-&gt;append(formattedOutput);
  }
  </code></pre>
  
  <p>I'm somehow missing the link: the XML data is already present, it can also be read by the <strong><em>xmlreader</em></strong>. The <strong><em>xmlwriter</em></strong> is configured to write into the QString <strong><em>formattedOutput</em></strong> and is also set to auto-format the output. But how can I get my XML data into the xmlwriter!? Or is this a completely wrong approach and there's an easier way to output XML from a string in a tidied-up shape?</p>
  
  <p>Thanks in advance for your help!</p>