public void writeTo(Writer writer) {
try {
if (node != null) {
PrintWriter printWriter = new PrintWriter(writer);
new XmlNodePrinter(printWriter).print(node);
printWriter.flush();
} else if (element != null) {
PrintWriter printWriter = new PrintWriter(writer);
XmlUtil.serialize(element, printWriter);
printWriter.flush();