Java tutorial
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; public class Main { /** * Get sub tag content. * @param node to process * @param tagName the tag name * @return the child content */ public static String getSubTagValue(Node node, String tagName) { if (node == null) { return null; } NodeList nodeList = node.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node n = nodeList.item(i); if (n instanceof Element) { if (((Element) n).getTagName().equals(tagName)) { Node nn = n.getFirstChild(); if (nn instanceof Text) { return ((Text) nn).getData(); } } } } return null; } }