Java tutorial
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * Gets node index * @param parentNode note in which the search * @param node seeking node * @return node index. -1 if node does not exists */ public static int getNodeIndex(Node parentNode, Node node) { NodeList list = parentNode.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { if (list.item(i).equals(node)) { return i; } } return -1; } }