code: public static void writeXmlNoSpace(Document doc, String encoding, Writer out)
          throws IOException {
          XMLSerializer ser = new XMLSerializer(out, getXmlNoSpace(encoding));
          
          ser.serialize(doc);
          out.close();
      }
docs: Serialize the dom Document with no preserved space between elements,
  but without indenting, line wrapping, omission of XML declaration, or
  omission of doctype
  @param doc
  @param encoding
  @param out
  @throws IOException