title: Pretty print with libxml2?
body: <p>Using libxml2.  I can pretty-print the XML into a file by using <code>xmlSaveFormatFileEnc()</code>.  But is there a way to do the same thing into a text string or stream?</p>
  
  <p>I'd like to avoid writing the XML out to a file and reading it back in just to get the pretty-print version of the XML.</p>
  
  <p>For the record, what I'm doing now is the following:</p>
  
  <pre><code>xmlInitParser();
  xmlKeepBlanksDefault(0);
  xmlLineNumbersDefault(1);
  xmlThrDefIndentTreeOutput(1);
  xmlThrDefTreeIndentString("    ");
  
  std::string content = "....."; // do something here to get the XML
  xmlDoc * doc = xmlParseDoc((xmlChar*)content.c_str());
  
  xmlSaveFormatFileEnc("output.xml", doc, "utf-8", 1); // pretty print
  </code></pre>