public static byte[] serializeNode(final Node xmlNode){
  try {
    final DOMImplementationRegistry registry=DOMImplementationRegistry.newInstance();
    final DOMImplementationLS impl=(DOMImplementationLS)registry.getDOMImplementation("LS");
    final LSSerializer writer=impl.createLSSerializer();
    final ByteArrayOutputStream buffer=new ByteArrayOutputStream();
    final LSOutput output=impl.createLSOutput();
    output.setByteStream(buffer);
    writer.write(xmlNode,output);
    final byte[] bytes=buffer.toByteArray();
    return bytes;
  }
 catch (  Exception e) {
    throw new DSSException(e);
  }
}

public static byte [ ] serializeNode ( final Node xmlNode ) { try { final DOMImplementationRegistry registry = DOMImplementationRegistry . newInstance ( ) ; final DOMImplementationLS impl = ( DOMImplementationLS ) registry . getDOMImplementation ( "LS" ) ; final LSSerializer writer = impl . createLSSerializer ( ) ; final ByteArrayOutputStream buffer = new ByteArrayOutputStream ( ) ; final LSOutput output = impl . createLSOutput ( ) ; output . setByteStream ( buffer ) ; writer . write ( xmlNode , output ) ; final byte [ ] bytes = buffer . toByteArray ( ) ; return bytes ; } catch ( Exception e ) { throw new DSSException ( e ) ; } }
document object model ( dom ) level 3 load and save specification see : http : / / www . w3 . org / tr / 2004 / rec - dom - level - 3 - ls - 20040407 /
