M
Mike Kennedy
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.newDocumentBuilder();
Document doc = builder.parse(in.xml);
FileWriter file = new FileWriter(out.xml);
// Create an XMLInputStream using the DOM we've changed
XMLInputStreamFactory ifactory =
XMLInputStreamFactory.newInstance();
XMLInputStream istream = ifactory.newInputStream(doc);
// Create an XMLOutputStream to generate a new output file
// using the file created earlier
XMLOutputStreamFactory ofactory =
XMLOutputStreamFactory.newInstance();
XMLOutputStream output =
ofactory.newOutputStream(new PrintWriter(file,true));
output.add(istream);
output.flush();
output.close();
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.newDocumentBuilder();
Document doc = builder.parse(in.xml);
FileWriter file = new FileWriter(out.xml);
// Create an XMLInputStream using the DOM we've changed
XMLInputStreamFactory ifactory =
XMLInputStreamFactory.newInstance();
XMLInputStream istream = ifactory.newInputStream(doc);
// Create an XMLOutputStream to generate a new output file
// using the file created earlier
XMLOutputStreamFactory ofactory =
XMLOutputStreamFactory.newInstance();
XMLOutputStream output =
ofactory.newOutputStream(new PrintWriter(file,true));
output.add(istream);
output.flush();
output.close();