Here you can find the source of evaluate(File xmlFile, String xPathExpression)
public static String evaluate(File xmlFile, String xPathExpression)
//package com.java2s; /*//from ww w.j av a2 s . co m * Copyright (c) 2010-2012 Research In Motion Limited. All rights reserved. * * This program and the accompanying materials are made available * under the terms of the Apache License, Version 2.0, * which accompanies this distribution and is available at * * http://www.apache.org/licenses/LICENSE-2.0 * */ import java.io.File; import java.io.FileInputStream; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory; import org.xml.sax.InputSource; public class Main { public static String evaluate(File xmlFile, String xPathExpression) { String result = null; try { XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); result = xPath.evaluate(xPathExpression, new InputSource(new FileInputStream(xmlFile))); } catch (Exception ex) { System.out.println(ex.getMessage()); } return result; } }