Java tutorial
//package com.java2s; import java.io.FileOutputStream; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; public class Main { private static String filepath = Thread.currentThread().getContextClassLoader().getResource("process.xml") .getPath(); public static synchronized void write2Xml(Document document) throws Exception { TransformerFactory.newInstance().newTransformer().transform(new DOMSource(document), new StreamResult(new FileOutputStream(filepath))); } }