Here you can find the source of getChild(Element parent, int i)
public static Element getChild(Element parent, int i)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static Element getChild(Element parent, int i) { NodeList children = parent.getChildNodes(); if (children.getLength() == 0) return null; int count = 0; for (int k = 0; k < children.getLength(); k++) { Node kid = children.item(k); if (kid instanceof Element) { if (count == i) return (Element) kid; else ++count;// www.java2 s . c o m } } return null; } }