title: How to remove duplicate XML declaration
body: <p>I am receiving following XML response via Jersey client</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;&lt;aaa&gt;&lt;bbb key="Data"&gt;&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;my-data xsi:noNamespaceSchemaLocation="MyData.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
      &lt;data name="abc" uniqueId="4fe95637-a381-4e0c-bf7f-49f794df5f23"&gt;
          &lt;variable var1="xyz" value="44"/&gt;        
      &lt;/data&gt;    
  &lt;/my-data&gt;
  &lt;/bbb&gt;&lt;/aaa&gt;
  </code></pre>
  
  <p>I am saving this as an XML file and getting 'premature end of file' error during parsing, since the XML is malformed (duplicate XML declarations)...is there a way to remove following duplicate entry from the output?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  </code></pre>
  
  <p>Following is my Java code snippet:</p>
  
  <pre><code> String output = response.getEntity(String.class); 
   file = writeResponseToFile(output,"MyData.xml");
   DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   dbf.setNamespaceAware(true);       
   DocumentBuilder db = dbf.newDocumentBuilder();
   Document document = db.parse(file);    //Error
  </code></pre>