Java tutorial
//package com.java2s; /* $This file is distributed under the terms of the license in /doc/license.txt$ */ import org.w3c.dom.Node; public class Main { /** * @param node */ public static void displayNodeInfo(Node node) { switch (node.getNodeType()) { case Node.DOCUMENT_NODE: System.out.println("Document Node "); break; case Node.ELEMENT_NODE: System.out.println("Element Node: " + node.getNodeName()); break; case Node.TEXT_NODE: System.out.println("Text Node: " + node.getNodeName()); break; case Node.CDATA_SECTION_NODE: System.out.println("CDATA Section Node: "); break; case Node.COMMENT_NODE: System.out.println("Comment Node "); break; case Node.PROCESSING_INSTRUCTION_NODE: System.out.println("Processing Instruction Node "); break; case Node.ENTITY_REFERENCE_NODE: System.out.println("Entity Reference Node "); break; case Node.DOCUMENT_TYPE_NODE: System.out.println("Document Type Node "); break; } } }