public void saveToFile(String filePath) throws Exception {
		if (filePath == null || filePath.equals("")) {
			throw new NullPointerException("File path is null.");
		}

		DocumentBuilderFactory docFactory = DocumentBuilderFactory
				.newInstance();
		DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
		Document doc = docBuilder.newDocument();

		Element rootElement = doc.createElement("document");
		doc.appendChild(rootElement);

		Element glyphsElement = doc.createElement("glyphs");
		rootElement.appendChild(glyphsElement);

		for (Glyph glyph : this.children) {
			Element glyphElement = glyph.toXmlElement(doc);
			glyphsElement.appendChild(glyphElement);
		}

		TransformerFactory transformerFactory = TransformerFactory
				.newInstance();
		Transformer transformer = transformerFactory.newTransformer();
		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 File(filePath));
		transformer.transform(source, result);
	}