Java tutorial
//package com.java2s; //License from project: Creative Commons License import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * Returns the first child of a node with a specified name. * * @param node The parent node. * @param name The name of the child. * @return The first child of <code>node</code> named <code>name</code>. */ public static Node getChildByName(Node node, String name) { try { NodeList list = node.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { if (list.item(i).getNodeName().equals(name)) { return list.item(i); } } return null; } catch (Exception e) { return null; } } }