Java tutorial
//package com.java2s; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { private static String unevaluatedXML(String result, Node node) { String nodeName = node.getNodeName(); String attributes = ""; if (node.hasAttributes()) { NamedNodeMap XMLAttributes = node.getAttributes(); for (int i = 0; i < XMLAttributes.getLength(); i++) { attributes += " " + XMLAttributes.item(i).getNodeName() + "=\"" + XMLAttributes.item(i).getNodeValue() + "\""; } } if (result.equals("")) return " <" + nodeName + attributes + "/> "; else return " <" + nodeName + attributes + ">" + result + "</" + nodeName + "> "; // add spaces } }