Skip to content

v2.4.2

Compare
Choose a tag to compare
@zhegexiaohuozi zhegexiaohuozi released this 27 Sep 02:58
· 42 commits to master since this release

test:
https://github.com/zhegexiaohuozi/JsoupXpath/blob/94fc9c79095c1909c552e1e7e6ef545d3271bdf4/src/test/java/org/seimicrawler/xpath/JXDocumentTest.java#L246

    @Test
    public void fixTextElNoParentTest(){
        String test="<div class='a'> a <div>need</div> <div class='e'> not need</div> c </div>";
        JXDocument j = JXDocument.create(test);
        List<JXNode> l = j.selN("//div[@class='a']//text()[not(ancestor::div[@class='e'])]");
        Set<String> finalRes = new HashSet<>();
        for (JXNode i : l){
            logger.info("{}",i.toString());
            finalRes.add(i.asString());
        }
        Assert.assertFalse(finalRes.contains("not need"));
        Assert.assertTrue(finalRes.contains("need"));
        Assert.assertEquals(4, finalRes.size());
    }