title: Remove the XML header from an XML in Java
body: <pre><code>StringWriter  writer = new StringWriter();
  XmlSerializer serializer = new KXmlSerializer();
  serializer.setOutput(writer);
  serializer.startDocument(null, null);
  serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
  // Creating XML
  
  serializer.endDocument();
  String xmlString = writer.toString();
  </code></pre>
  
  <p>In the above environment, whether there are any standard API's available to remove the XML header <code>&lt;?xml version='1.0' ?&gt;</code> or do you suggest to go via string manipulation:</p>
  
  <pre><code>if (s.startsWith("&lt;?xml ")) {
      s = s.substring(s.indexOf("?&gt;") + 2);
  }
  </code></pre>
  
  <p>Wanted the output in the <code>xmlString</code> without XML header info <code>&lt;?xml version='1.0' ?&gt;</code>.</p>