Code example for XPath

Methods: evaluate

0
        /* 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) { 
                    } 
                } 
            }; 
        } 
 
        /* a <test> with a nested <valueOf>, both of which have select attributes */ 
        NodeList valueOfElements = element.getElementsByTagName("valueOf"); 
        if (valueOfElements.getLength() == 1) { 
            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 {