public void saveXml(File file) {
		try {
			if (!file.exists()) {
				file.createNewFile();
			}
			FileOutputStream fileStream = new FileOutputStream(file);
			String empty = "<library></library>";
			for (int i = 0; i < empty.length(); i++) {
				fileStream.write(empty.charAt(i));
			}
			fileStream.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		try {
			DocumentBuilder builder = factory.newDocumentBuilder();
			Document library = builder.parse(file);
			Element root = library.getDocumentElement();
			for (int i = 0; i < parent.tracks.size(); i++) {
				Element thisNode = library.createElement("track");
				Track thisTrack = parent.tracks.get(i);

				thisNode.setAttribute("id", String.valueOf(thisTrack.getId()));
				thisNode.setAttribute("author", String.valueOf(thisTrack.getAuthor()));
				thisNode.setAttribute("title", String.valueOf(thisTrack.getTitle()));
				thisNode.setAttribute("part", String.valueOf(thisTrack.getPart()));
				thisNode.setAttribute("bpm", String.valueOf(thisTrack.getBpm()));
				thisNode.setAttribute("keyFr", String.valueOf(thisTrack.getKeyFr()));
				thisNode.setAttribute("frPerBpm", String.valueOf(thisTrack.getFrPerBpm()));
				thisNode.setAttribute("tempoForRef", String.valueOf(thisTrack.getTempoForRef()));
				thisNode.setAttribute("refFr", String.valueOf(thisTrack.getRefFr()));
				thisNode.setAttribute("keyNotes", String.valueOf(thisTrack.getKeyNotes()));

				Element allMatches = library.createElement("matches");
				for (int j = 0; j < thisTrack.matches.length; j++) {
					if (thisTrack.matches[j] != 0) {
						Element matchNode = library.createElement("match");
						matchNode.setAttribute("id", String.valueOf(j));
						matchNode.setAttribute("type", String.valueOf(thisTrack.matches[j]));
						allMatches.appendChild(matchNode);
					}
				}
				thisNode.appendChild(allMatches);
				root.appendChild(thisNode);
			}

			Source source = new DOMSource(library);
			TransformerFactory fabrique = TransformerFactory.newInstance();
			Transformer transformer = fabrique.newTransformer();
			transformer.setOutputProperty(OutputKeys.INDENT, "yes");
			transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
			javax.xml.transform.Result resultat = new StreamResult(file);
			transformer.transform(source, resultat);

		} catch (Exception e) {
			System.out.println("exception : " + e.getMessage());
		}
	}