Code example for XPath

Methods: compile, setNamespaceContext

0
     
		XPathFactory factory = XPathFactory.newInstance();
		XPath xpath = factory.newXPath();
		if (resolver != null)
		  { 
				xpath.setNamespaceContext(new DomNSResolverContext(resolver));
	 	  } 
    try 
      { 
        this.expression = xpath.compile(expression);
      } 
    catch (XPathExpressionException e)
      { 
        throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,
						                     e.getMessage ());
      } 
  } 
 
  public Object evaluate(Node contextNode, short type, Object result)
    throws XPathException, DOMException 
  {