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

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -