Here you can find the source of printElement(Element e)
public static void printElement(Element e)
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**/* ww w. ja v a2 s . c o m*/ * Utility method for displaying an Element */ public static void printElement(Element e) { printElement(e, ""); } /** * Utility method for displaying an Element, with indent control */ public static void printElement(Element e, String prefix) { System.out.print(prefix + e.getTagName() + " "); NamedNodeMap attrs = e.getAttributes(); for (int i = 0; i < attrs.getLength(); i++) { Node att = attrs.item(i); System.out.print(att.getNodeName() + "=" + att.getNodeValue() + " "); } System.out.println(); NodeList children = e.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child instanceof Element) printElement((Element) child, prefix + " "); else System.out.println(prefix + child.getNodeName() + " " + child.getNodeValue()); } } }