Java tutorial
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static String getChildNodeValue(String nodeName, Node parent) { if (parent == null) { return null; } NodeList childNodes = parent.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeName().equals(nodeName)) { Node firstChild = node.getFirstChild(); if ((firstChild != null) && (firstChild.getNodeType() == Node.TEXT_NODE)) { return firstChild.getNodeValue(); } else { return null; } } } } return null; } }