I want to use w3c.dom to update xml and create a new file. I had use transform like this:
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(newXml);
StreamResult result = new StreamResult(target);
transformer.transform(source, result);
I use setTextContent to update a document file to newxml, but the new file(result) encoding is different with newXml. I know that I can use
transformer.setOutputProperty(OutputKeys.ENCODING, newXml.getXmlEncoding());
but I hope the result document type and encoding typesetting is same with original file(newXml).
Hope someone to know how to do, thank you~