Java tutorial
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * Retrieves the value of a child node given the name of the child node. * * @param node * @param childNodeName * @return */ public static String getChildValue(Node node, String childNodeName) { NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node n = children.item(i); if (n.getNodeName().equals(childNodeName)) { return getNodeValue(n); } } return null; } /** * Retrieves the value of a node (i.e, its text content) * * @param node * @return */ public static String getNodeValue(Node node) { return node.getTextContent(); } }