3 * Copyright 2011 IAAS University of Stuttgart <br>
6 * @author uwe.breitenbuecher@iaas.uni-stuttgart.de
9 package de.unistuttgart.iaas.xml;
11 import javax.xml.namespace.QName;
12 import javax.xml.xpath.XPath;
13 import javax.xml.xpath.XPathFactory;
16 public class XPathEvaluator {
18 public static XPath xpath = XPathFactory.newInstance().newXPath();
21 @SuppressWarnings("unchecked")
22 public static <t> t evaluate(String expression, Object source, QName returnType) {
24 Object resultAsObject = null;
26 resultAsObject = xpath.evaluate(expression, source, returnType);
28 } catch (Exception e) {
31 return (t) resultAsObject;