Java tutorial
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static String getElementValueByTagName(Element root, String tagName) { NodeList nodes = root.getElementsByTagName(tagName); if (nodes != null) { Node node = nodes.item(0).getFirstChild(); if (node != null) { return node.getNodeValue(); } else { return null; } } else { return null; } } }