About Users Other Info (External) |
000036-NotesUsing a Transformer in ConvetionalParser: TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2" ); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(new FileOutputStream(path)); transformer.transform(source, result); |