private void writeXML(Document doc, PreviewPreset preset) { Element presetE = doc.createElement("previewpreset"); presetE.setAttribute("name", preset.getName()); presetE.setAttribute("version", "0.8.1"); for (Entry<String, Object> entry : preset.getProperties().entrySet()) { String propertyName = entry.getKey(); try { Object propertyValue = entry.getValue(); if (propertyValue != null) { String serialized = PreviewProperties.getValueAsText(propertyValue); if (serialized != null) { Element propertyE = doc.createElement("previewproperty"); propertyE.setAttribute("name", propertyName); propertyE.setAttribute("class", propertyValue.getClass().getName()); propertyE.setTextContent(serialized); presetE.appendChild(propertyE); } } } catch (Exception ex) { Exceptions.printStackTrace(ex); } } doc.appendChild(presetE); }