Here you can find the source of parseToString(final Node node)
public static String parseToString(final Node node) throws TransformerFactoryConfigurationError, TransformerException
//package com.java2s; /**// ww w . java2 s .com * PETALS - PETALS Services Platform. Copyright (c) 2007 EBM Websourcing, * http://www.ebmwebsourcing.com/ * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. This library is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ------------------------------------------------------------------------- * $Id: Router.java,v 1.2 2006/03/17 10:24:27 alouis Exp $ * ------------------------------------------------------------------------- */ import java.io.StringWriter; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Node; public class Main { public static String parseToString(final Node node) throws TransformerFactoryConfigurationError, TransformerException { String result = null; if (node != null) { node.normalize(); Transformer transformer = TransformerFactory.newInstance().newTransformer(); StringWriter stringWriter = new StringWriter(); transformer.transform(new DOMSource(node), new StreamResult(stringWriter)); StringBuffer buffer = stringWriter.getBuffer(); result = buffer.toString(); } return result; } }