Code example for XPath

Methods: evaluate

0
            final Element valueOf = (Element) valueOfElements.item(0); 
            final String valueOfSelect = valueOf.getAttribute("select"); 
 
            return new XPathTest(context, select) { 
                @Override void test(Node contextNode) throws XPathExpressionException {
                    Node newContext = (Node) xpath.evaluate(
                            select, contextNode, XPathConstants.NODE);
                    assertEquals(valueOf.getTextContent(), 
                            xpath.evaluate(valueOfSelect, newContext, XPathConstants.STRING));
                } 
            }; 
        } 
 
        /* 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());