简体   繁体   中英

How to select an element in Jsoup using its html content?

I want to select an element in Jsoup using its html content.

Example: LOCATION:

How can i do it. I couldn't find any approriate selector methods directly. Is there any work around available?

Using Jsoup library you can parse from value from html using name, ID or class of element.

String html = "<html><head><title>Title</title></head> <body><div id='location'>Mumbai, India</div></body></html>";
Document document= Jsoup.parse(html);
String content = document.getElementById("location").outerHtml();

Happy Coding :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM