Java tutorial
//package com.java2s; import org.w3c.dom.*; import java.util.ArrayList; public class Main { /** * Returns the index of an element node from a provided list * @param actAllNodes * @param element * @param exceptionList - a list of indexes that will not be taken in count * @return -1 if node not found in the list */ protected static int isNodePresent(NodeList actAllNodes, Element element, ArrayList<Integer> exceptionList) { int idx = -1; int tmpIdx = -1; try { String tmpElementName = element.getNodeName(); for (int i = 0; i < actAllNodes.getLength(); i++) { if (actAllNodes.item(i).getNodeName().equals(tmpElementName)) { tmpIdx = i; if (exceptionList.indexOf(tmpIdx) == -1) { idx = tmpIdx; break; } } } return idx; } catch (Exception e) { e.printStackTrace(); return -1; } } }