Element element = new Element("pre:foo", "http://www.example.org");
root.appendChild(element);
element.appendChild(" value \n value");
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
Canonicalizer serializer = new Canonicalizer(out, Canonicalizer.EXCLUSIVE_XML_CANONICALIZATION);
serializer.write(element);
}
finally {
out.close();
}
byte[] actual = out.toByteArray();