atom feed2 messages in net.sourceforge.lists.saxon-helpRe: [saxon] saxon-nodeinfo
FromSent OnAttachments
citraviFeb 22, 2007 1:10 pm 
Michael KayFeb 23, 2007 9:50 am 
Subject:Re: [saxon] saxon-nodeinfo
From:Michael Kay (mi@saxonica.com)
Date:Feb 23, 2007 9:50:38 am
List:net.sourceforge.lists.saxon-help

How can I get xml text of the nodeinfo (like node.asXML() in dom4j)?

Create a serializer and then write the node to the serializer:

public static String serialize(NodeInfo nodeInfo) throws XPathException { Configuration config = nodeInfo.getConfiguration(); StringWriter sw = new StringWriter(); Properties props = new Properties(); props.setProperty("method", "xml"); props.setProperty("indent", "yes"); Receiver serializer = config.getSerializerFactory().getReceiver( new StreamResult(sw), config.makePipelineConfiguration(), props); nodeInfo.copy(serializer, NodeInfo.ALL_NAMESPACES, true, 0); return sw.toString(); }