Here you can find the source of stringifyNode(Node node)
public static String stringifyNode(Node node)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013,2014 Red Hat, Inc. * Distributed under license by Red Hat, Inc. All rights reserved. * This program is made available under the terms of the * Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*www . j a va2 s. c o m*/ * Red Hat, Inc. - initial API and implementation ******************************************************************************/ import java.io.ByteArrayOutputStream; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; 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 stringifyNode(Node node) { try { Transformer transformer = TransformerFactory.newInstance().newTransformer(); Source source = new DOMSource(node); ByteArrayOutputStream out = new ByteArrayOutputStream(); Result result = new StreamResult(out); transformer.transform(source, result); return out.toString(); } catch (TransformerConfigurationException e) { return null; } catch (TransformerFactoryConfigurationError e) { return null; } catch (TransformerException e) { return null; } } }