Code example for Transformer

Methods: setOutputPropertytransform

		TransformerFactory tfactory = TransformerFactory.newInstance();
		Transformer serializer;
		try { 
			serializer = tfactory.newTransformer();
			// Setup indenting to "pretty print" 
			serializer.setOutputProperty(OutputKeys.INDENT, "yes");
			serializer.setOutputProperty("{}indent-amount", "2");
			serializer.transform(new DOMSource(doc), new StreamResult(out));
		} catch (TransformerException e) {
			// this is fatal, just dump the stack and throw a runtime exception 
			throw new RuntimeException(e);
Stop searching for code, let great code find you!  Add Codota to your java IDE