Here you can find the source of getXmlString(Node inXml, String xpath)
public static String getXmlString(Node inXml, String xpath)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import javax.xml.xpath.XPath; public class Main { private static XPath xPath; public static String getXmlString(Node inXml, String xpath) { if (!xpath.contains("/")) { NodeList elements = ((Element) inXml).getElementsByTagName(xpath); if (elements.getLength() == 1) { return elements.item(0).getTextContent(); }// w ww. j av a 2s . co m } try { return xPath.evaluate(xpath, inXml); } catch (Exception ex) { throw new RuntimeException("Could not run xpath: " + xpath, ex); } } }