css selectors - Getting text of element without including text of sub-element with jsoup -
i'm using jsoup parse html. there list items this:
<li><span class="chk">x</span>category name</li>
i want text of li not including text of span. want "category name" without "x". (if invoke text()
method on li element, "xcategory name".) how can exclude sub-span?
owntext() method help here.
document document = jsoup.parse("<ul><li><span class=\"chk\">x</span>home</li><li><spanclass=\"chk\">x</span>category name</li></ul>"); elements elems = document.select("li"); for(element elem : elems){ system.out.println(elem.owntext()); }
css-selectors jsoup
No comments:
Post a Comment