Java tutorial
//package com.java2s; /* * Misc-Utils - Miscellaneous Utility Classes * Copyright (C) 2007 Newisys, Inc. or its licensors, as applicable. * Java is a registered trademark of Sun Microsystems, Inc. in the U.S. or * other countries. * * Licensed under the Open Software License version 3.0 (the "License"); you * may not use this file except in compliance with the License. You should * have received a copy of the License along with this software; if not, you * may obtain a copy of the License at * * http://opensource.org/licenses/osl-3.0.php * * This software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ import org.w3c.dom.Node; public class Main { /** * Dumps a debug listing of the child nodes of the given node to * System.out. * * @param node the node to dump the children of */ public static void dumpChildren(Node node) { System.out.println("Children of " + node.getNodeName() + ", NS: " + node.getNamespaceURI() + ", Type: " + node.getClass()); Node child = node.getFirstChild(); while (child != null) { short nodeType = child.getNodeType(); String nodeName = child.getNodeName(); String nodeValue = child.getNodeValue(); String nsURI = child.getNamespaceURI(); System.out.println(" Type: " + nodeType + ", Name: " + nodeName + ", Value: " + nodeValue + ", NS: " + nsURI + ", Type: " + node.getClass()); child = child.getNextSibling(); } } }