public static Element selectElement(XPathExpression expr,Node context){
  try {
    Object result=expr.evaluate(context,XPathConstants.NODE);
    if (result == null) {
      return null;
    }
 else     if (result instanceof Element) {
      return (Element)result;
    }
 else {
      throw new XmlException("Not an element: " + result);
    }
  }
 catch (  XPathExpressionException e) {
    throw new XmlException(e);
  }
}

public static Element selectElement ( XPathExpression expr , Node context ) { try { Object result = expr . evaluate ( context , XPathConstants . NODE ) ; if ( result == null ) { return null ; } else if ( result instanceof Element ) { return ( Element ) result ; } else { throw new XmlException ( "Not an element: " + result ) ; } } catch ( XPathExpressionException e ) { throw new XmlException ( e ) ; } }
evaluates the xpath expression to a single element .
