I have an element like this :
<td> TextA <br/> TextB </td>
How can I extract TextA and TextB separately?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Several ways. That really depends on the document itself and whether the given HTML markup is consistent or not. In this particular example you could get the
td‘s child nodes byElement#childNodes()and then test every node individually if it’s aTextNodeor not.E.g.
which results in
I think it would be nice if Jsoup offered a
Element#textNodes()or something to get the child text nodes like asElement#children()does to get the child elements (which would have returned the<br />element in your example).