Code example for XPath

Methods: evaluate

0
        /* Such as <test select="..." count="5"/> */ 
        final String count = element.getAttribute("count");
        if (count.length() > 0) { 
            return new XPathTest(context, select) { 
                @Override void test(Node contextNode) throws XPathExpressionException {
                    NodeList result = (NodeList) xpath.evaluate(
                            select, contextNode, XPathConstants.NODESET);
                    assertEquals(Integer.parseInt(count), result.getLength());
                } 
            }; 
        } 
 
        throw new UnsupportedOperationException("Unsupported test: " + context); 
    } 
 
    /** 
     * Returns the test described by the given {@code <valueOf>} element. These 
     * tests select an expected text. 
     */ 
    private static TestCase createFromValueOf(
            final XPath xpath, final Context context, final Element element) {