Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;
import java.util.Iterator;

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

public class Main {
    public static Node SearchNode(NodeList listNode, ArrayList<String> arrStrCompare) {
        ArrayList<String> arrTempList = arrStrCompare;
        Iterator<String> iterator = arrTempList.iterator();

        while (iterator.hasNext()) {
            String strCompare = (String) iterator.next();
            iterator.remove();

            for (int i = 0; i < listNode.getLength(); i++) {
                Node node = listNode.item(i);

                if (strCompare.equals(node.getNodeName())) {
                    if (iterator.hasNext()) {
                        return SearchNode(node.getChildNodes(), arrTempList);
                    }
                    String strResp = node.getTextContent();
                    System.out.println("Found DATA [" + strCompare + "]: " + strResp);
                    return node;
                }
            }
        }

        return null;
    }
}