Scott Cantor wrote:
> >> You don't happen to have a code snippet around that does exactly that >> (Java)? >> > > I don't do Java any more (see headache above). The xmltooling code underneath > opensaml-j, which I didn’t write, has helper routines that provide one way to > do it, and they appear to use a DOM3 LSSerializer: > > public static void writeNode(Node node, Writer output) { > DOMImplementation domImpl = node.getOwnerDocument().getImplementation(); > DOMImplementationLS domImplLS = (DOMImplementationLS) > domImpl.getFeature("LS", "3.0"); > LSSerializer serializer = domImplLS.createLSSerializer(); > LSOutput serializerOut = domImplLS.createLSOutput(); > serializerOut.setCharacterStream(output); > serializer.write(node, serializerOut); > } > > There's also a pretty-print version that seems to be similar to what you're > doing but not exactly the same. > I was just about to send this out, but Scott beat me to it. :-) Here's where that code comes from: http://svn.middleware.georgetown.edu/view/trunk/src/org/opensaml/xml/util/XMLHelper.java?root=java-xmltooling&view=markup It's often used via the nodeToString(): public static String nodeToString(Node node) { StringWriter writer = new StringWriter(); writeNode(node, writer); return writer.toString(); } These 2 methods are by and large how we serialize DOM elements in the Java version of OpenSAML, and seems to work quite successfully with signature and encryption. --Brent