Hi, xpath is missing some basic functions like not, contains, etc.
It would be great if we are able to execute the following code:
String html = "<!DOCTYPE HTML><html><body><div class=\"bb ccc\">from: <b>20</b></div><div/></body></html>";
for (String xpath : Arrays.asList(
"//div[not(@class)]",
"//div[contains(@class,'bb')]",
"//div[contains(text(),'from:')]/b/text()",
"/html/body/div[last()-1]")) {
CleanerProperties props = new CleanerProperties();
props.setOmitDoctypeDeclaration(true);
TagNode tagNode = new HtmlCleaner(props).clean(html);
Object[] res = tagNode.evaluateXPath(xpath);
assert (res.length > 0);
}
Regards
R.
Hello,
I implemented the function not() for xpath and I attach the patch of the XPather.java .Check if it is as it should be.Thanks.