public static void writeXML(String path, Document toWrite)
			throws TransformerException, FileNotFoundException {
		TransformerFactory factory = TransformerFactory.newInstance();
		Transformer transf = factory.newTransformer();
		transf.setOutputProperty(OutputKeys.INDENT, "yes");
		transf.setOutputProperty("{http://xml.apache.org/xslt}-indent-amount",
				"2");
		DOMSource src = new DOMSource(toWrite);
		StreamResult r = new StreamResult(new FileOutputStream(path));
		transf.transform(src, r);
	}