@Override
	public void write(String string) {
		try {

			checkForDirectory();		
			
			File xmlFile = new File("C:\\calcXmlFiles\\calc.xml");
			boolean newFileFlag = false;
			if (!xmlFile.exists()) {
				newFileFlag = true;
				xmlFile.createNewFile();
			}

			DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance();
			DocumentBuilder documentBuilder = documentFactory.newDocumentBuilder();
			Document doc = null;
			Element root = null;

			if (newFileFlag) {
				doc = documentBuilder.newDocument();
				root = doc.createElement("calc");
				doc.appendChild(root);
			} else {
				doc = documentBuilder.parse(xmlFile);
				root = doc.getDocumentElement();
			}

			Element element = doc.createElement("expression");

			element.appendChild(doc.createTextNode(string));
			root.appendChild(element);

			TransformerFactory transformerFactory = TransformerFactory.newInstance();
			Transformer transformer = transformerFactory.newTransformer();
			DOMSource domSource = new DOMSource(doc);

			StreamResult streamResult = new StreamResult(xmlFile);

			transformer.transform(domSource, streamResult);

		} catch (ParserConfigurationException pce) {
			pce.printStackTrace();
		} catch (TransformerException tfe) {
			tfe.printStackTrace();
		} catch (SAXException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}