I've got a html element that looks like this:
<p>
<strong>Popular resonses: </strong>
bat, butterfly, moth
</p>
Html contains about all elements with <p> tag.
I need to extract <p> values (bat, butterfly, moth).
Thanks.
P.S
I've tried to parse with Matcher and Pattern but it did'n work.
I'm using JSoup as parsing library.
You can get your desired text by using -
This will find all the
pelements in the html that contains alsostrong, and print the text that belongs only to thepbut not to thestrong-If you use
e.text()instead, you will get all the text in thepelement -If you have only one such element you can also use -
Which saves you the loop.