try {
StringWriter stringWriter = new StringWriter();
OutputFormat format = new OutputFormat("XML", "ISO-8859-1", true);
format.setLineWidth(0);
XMLSerializer serializer = new XMLSerializer(stringWriter, format);
serializer.asDOMSerializer().serialize(document);
/* We don't want the newline character at the end */
String string = stringWriter.toString();
return string.substring(0, string.length() - 1);
} catch (Exception e) {
throw new GUIException("Could not serialize XML", e);