Here you can find the source of nodeToString(Node node)
public static String nodeToString(Node node)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { public static String nodeToString(Node node) { String ret = "<null/>"; if (node != null) { ret = "<" + node.getNodeName() + " "; NamedNodeMap attrs = node.getAttributes(); if (attrs != null) { for (int i = 0; i < attrs.getLength(); i++) { Node attr = (Node) attrs.item(i); ret = ret + attr.getNodeName() + "='"; ret = ret + attr.getNodeValue() + "' "; }//from w w w . j a v a 2 s.c om } ret = ret + "/>"; } return ret; } }