Java tutorial
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Node; public class Main { public static Node findFirstChild(final Node n, final String name) { for (int i = 0; i < n.getChildNodes().getLength(); i++) { if (n.getChildNodes().item(i).getNodeName().equals(name)) { return n.getChildNodes().item(i); } } throw new IllegalStateException("no " + name + " children found in: " + n.getNodeName()); } }