Here you can find the source of selectString(String xpath, Object node)
public static String selectString(String xpath, Object node)
//package com.java2s; //License from project: Open Source License import javax.xml.namespace.QName; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; public class Main { public static String selectString(String xpath, Object node) { return ((String) evaluateXPath(xpath, node, XPathConstants.STRING)).trim(); }/*w ww . jav a 2s.co m*/ public static Object evaluateXPath(String xpath, Object item, QName returnType) { try { return XPathFactory.newInstance().newXPath().compile(xpath).evaluate(item, returnType); } catch (XPathExpressionException e) { throw new IllegalArgumentException(e); } } }