Code example for XPathExpression

Methods: evaluate

0
	 
	private static Object extract(Document doc, QName qname, String xpath) {
		Object result = "";
		try { 
			XPathExpression expr = xPath.compile(xpath);
			result = expr.evaluate(doc, qname);
		} catch (Exception e) {
			logger.log(Level.SEVERE, "Failed extracting xpath:" + xpath, e);
		} 
		return result;
	} 
 
	public static String extractString(Document doc, String xpath) {
		return (String) extract(doc, XPathConstants.STRING, xpath);
	} 
	 
	public static Document getDocument(HttpClient httpclient, String url) {
		HttpResponse response = httpGet(httpclient, url);
		DataController.validateResponse(response, url);
		InputStream inputStream = DataController.getContentStream(response.getEntity());
		return DataController.getDocument(inputStream);