I have an XML Snippet <?xml version="1.0" encoding="UTF-8"?> and when I
convert the entire xml file to a DOM and then generate a new file from
the DOM, results in <?xml version="1.0"?> .
Any thoughts?
My sample code snippet is:
DocumentBuilder builder = factory.newDocu mentBuilder();
Document doc = builder.parse(i n.xml);
FileWriter file = new FileWriter(out. xml);
// Create an XMLInputStream using the DOM we've changed
XMLInputStreamF actory ifactory =
XMLInputStreamF actory.newInsta nce();
XMLInputStream istream = ifactory.newInp utStream(doc);
// Create an XMLOutputStream to generate a new output file
// using the file created earlier
XMLOutputStream Factory ofactory =
XMLOutputStream Factory.newInst ance();
XMLOutputStream output =
ofactory.newOut putStream(new PrintWriter(fil e,true));
output.add(istr eam);
output.flush();
output.close();