Android examples for XML:XML Node
go recursively deep to find the XML node with the name
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**//ww w . j ava 2 s. c om * this function will go recursively deep to find the node with the name * * @param n * @param name * @return */ public static Node getNodeByName(Node n, String name) { NodeList l = n.getChildNodes(); //System.out.println("NodeList length:" + l.getLength()); if (l == null) return null; for (int i = 0; i < l.getLength(); i++) { if (l.item(i).getNodeName().equals(name)) return l.item(i); else { Node n2 = getNodeByName(l.item(i), name); if (n2 != null) { return n2; } } } return null; } }