Code example for XPath

Methods: evaluate

0
     *   <li>Expected failures. 
     *   <li>String matches. These tests have a nested {@code <valueOf>} element 
     *       that sub-selects an expected text. 
     *   <li>Count matches. These tests specify how many nodes are expected to 
     *       match. 
     * </ul> 
     */ 
    private static TestCase createFromTest(
            final XPath xpath, final Context context, final Element element) {
        final String select = element.getAttribute("select"); 
 
        /* Such as <test exception="true" select="..." count="0"/> */ 
        if (element.getAttribute("exception").equals("true")) { 
            return new XPathTest(context, select) { 
                @Override void test(Node contextNode) { 
                    try { 
                        xpath.evaluate(select, contextNode); 
                        fail("Expected exception!"); 
                    } catch (XPathExpressionException expected) { 
                    } 
                }