src/main/java/org/jsoup/helper/W3CDom.java
/**
     Evaluate an XPath query against the supplied context node, and return the results.
     @param xpath an XPath query
     @param contextNode the context node to evaluate against
     @return the matches nodes
     */
Evaluate an XPath query against the supplied context node, and return the results.
Evaluate an XPath query against the supplied context node and return the results .
public NodeList selectXpath(String xpath, Node contextNode) {
        Validate.notEmpty(xpath);
        Validate.notNull(contextNode);
        NodeList nodeList;
        try {
            String property = System.getProperty(XPathFactoryProperty);
            final XPathFactory xPathFactory = property != null ?
                XPathFactory.newInstance("jsoup") :
                XPathFactory.newInstance();
            XPathExpression expression = xPathFactory.newXPath().compile(xpath);
            nodeList = (NodeList) expression.evaluate(contextNode, XPathConstants.NODESET); 
            Validate.notNull(nodeList);
        } catch (XPathExpressionException | XPathFactoryConfigurationException e) {
            throw new Selector.SelectorParseException("Could not evaluate XPath query [%s]: %s", xpath, e.getMessage());
        }
        return nodeList;
    }
public NodeList selectXpath ( String xpath , Node contextNode ) { Validate . notEmpty ( xpath ) ; Validate . notNull ( contextNode ) ; NodeList nodeList ; try { String property = System . getProperty ( XPathFactoryProperty ) ; final XPathFactory xPathFactory = property != null ? XPathFactory . newInstance ( "jsoup" ) : XPathFactory . newInstance ( ) ; XPathExpression expression = xPathFactory . newXPath ( ) . compile ( xpath ) ; nodeList = ( NodeList ) expression . evaluate ( contextNode , XPathConstants . NODESET ) ; Validate . notNull ( nodeList ) ; } catch ( XPathExpressionException | XPathFactoryConfigurationException e ) { throw new Selector . SelectorParseException ( "Could not evaluate XPath query [%s]: %s" , xpath , e . getMessage ( ) ) ; } return nodeList ; }
Evaluate an XPath query against the supplied context node, and return the results.
Evaluate an XPath query against the supplied context node and return the results .
// if there is a configured XPath factory, use that instead of the Java base impl: // love the strong typing here /s