You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Felix Garcia Romero <fe...@tdi.tudistrito.es> on 2001/05/25 09:23:35 UTC
NodeList to String
How can I pass a NodeList to String, in the samples the code to generate the
result to console output is:
NodeList nl=......
int n=nl.getLength();
for (int i=0;i<n ; i++)
{
serializer.transform(new DOMSource(nl.item(i)), new
StreamResult(System.out));
}
How can I do to set the result in a String instead of System.out.
Thanks in advance
Re: NodeList to String
Posted by Edward Nesterov <ed...@quadrix.com>.
Hi,
Try this:
StringWriter sw = new StringWriter();
serializer.transform(new DOMSource(nl.item(i)), new StreamResult(sw));
String result = sw.toString();
Good luck.
Felix Garcia Romero wrote:
> How can I pass a NodeList to String, in the samples the code to
> generate the result to console output is: NodeList nl=...... int
> n=nl.getLength();
> for (int i=0;i<n ; i++)
> { serializer.transform(new DOMSource(nl.item(i)), new
> StreamResult(System.out));
>
> } How can I do to set the result in a String instead of
> System.out.Thanks in advance