About w3c dom to update xml file

x81kilo

New Member
I want to use w3c.dom to update xml and create a new file. I had use transform like this:\[code\]TransformerFactory transformerFactory = TransformerFactory.newInstance();Transformer transformer = transformerFactory.newTransformer();DOMSource source = new DOMSource(newXml);StreamResult result = new StreamResult(target);transformer.transform(source, result);\[/code\]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 \[code\]transformer.setOutputProperty(OutputKeys.ENCODING, newXml.getXmlEncoding());\[/code\]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~
 
Back
Top