Java tutorial
//package com.java2s; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactoryConfigurationError; public class Main { private static Transformer tx = null; private static boolean isInited = false; public static void init() { if (isInited) { return; } try { tx = TransformerFactory.newInstance().newTransformer(); tx.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); tx.setOutputProperty(OutputKeys.INDENT, "no"); isInited = true; } catch (TransformerFactoryConfigurationError | TransformerConfigurationException | IllegalArgumentException e) { e.printStackTrace(); } } }