Java XML NodeList printNode(NodeList nodeList, int level)

Here you can find the source of printNode(NodeList nodeList, int level)

Description

print Node

License

Open Source License

Declaration

private static void printNode(NodeList nodeList, int level) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    private static int depthOfXML = 1;

    private static void printNode(NodeList nodeList, int level) {
        level++;/*from w  w w . j  a  va 2  s  . com*/
        if (nodeList != null && nodeList.getLength() > 0) {
            for (int i = 0; i < nodeList.getLength(); i++) {
                Node node = nodeList.item(i);
                if (node.getNodeType() == Node.ELEMENT_NODE) {
                    System.out.println(node.getNodeName() + "[" + level + "]");
                    printNode(node.getChildNodes(), level);
                    // how depth is it?
                    if (level > depthOfXML)
                        depthOfXML = level;
                }
            }
        }
    }
}

Related

  1. parserXml(NodeList employees, Class class_type)
  2. parseSwitcherConfigs(NodeList switcherConfigNodes)
  3. parseSwitchers(NodeList switcherNodes)
  4. parseWidget(NodeList widgetList)
  5. prettyPrintLoop(NodeList nodes, StringBuilder string, String indentation)
  6. printNodeList(NodeList nodes)
  7. printNodeTypes(NodeList rows)
  8. removeBlankTextNode(NodeList nodes)
  9. removeNodeListContent(NodeList nodeList)