title: Java- how to obtain full xml stored in modified DOM Document
body: <p>I am using standard Java DOM parser to process an xml file-</p>
  
  <p>I have processed it and made changes to the xml document, now I want to view the modified xml.
  How do I store the modified XML into a string variable.</p>
  
  <p>For your reference, the code I am using is given below--</p>
  
  <pre><code>        str = "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;&lt;config&gt;&lt;var-def name=\"initial_no\"&gt;3972971&lt;/var-def&gt;&lt;var-def name=\"webpage\"&gt;asdf&lt;/var-def&gt;&lt;cloudwhile condition=\"${i.toInt() != 500}\" index=\"i\" returnvalue=\"false\" indexstart=\"1\" upperbound=\"500\"&gt;&lt;var-def name=\"webpage\" overwrite=\"true\"&gt;&lt;cloudwhile condition=\"${i.toInt() != 500}\" index=\"i\" returnvalue=\"false\" indexstart=\"100\" upperbound=\"700\"&gt;&lt;/cloudwhile&gt;&lt;try&gt;&lt;body&gt;&lt;http url=\"www.google.com/patents/US${initial_no.toInt()+i.toInt()}\"/&gt;&lt;/body&gt;&lt;catch&gt;ERROR- No content found for this patent number.&lt;/catch&gt;&lt;/try&gt;&lt;/var-def&gt;&lt;file action=\"write\" path=\"data/${initial_no.toInt()+i.toInt()}_content.html\"&gt;&lt;var name=\"webpage\"/&gt;&lt;/file&gt;&lt;/cloudwhile&gt;&lt;/config&gt;";
          InputStream is = new ByteArrayInputStream(str.getBytes("UTF-8"));
          DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
          DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
          Document doc = docBuilder.parse(is);
                      //some processing..
  </code></pre>