Jsoup select parent of direct child -
i'm trying select elements <p> tag direct child.
i've tried using following
*:has(p) but doesn't return direct parents.
use element.parent(), parent of element.
string html = "<div> blah <p> </p> </div>"; document doc = jsoup.parsebodyfragment(html); element p = doc.select("p").first(); string mytext = p.parent().text(); //selects enclosing div, , gets text in div. system.out.println(mytext); prints:
blah afaik, there no selector parent, have go th parent() method.
Comments
Post a Comment