By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,237 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,237 IT Pros & Developers. It's quick & easy.

jSoup to get text from <span> class

P: 1
I have a part of the HTML file with the following format:

Expand|Select|Wrap|Line Numbers
  1. <h6 class="uiStreamMessage" data-ft=""> 
  2.    <span class="messageBody" data-ft="">Twisted<a href="http://"><span>http://</span>
  3.    <span class="word_break"></span></a> Balloons
  4.    </span>
  5. </h6>
In the file, there are other span classes. But I would like to get the text for ALL 'messageBody' span only in the html file, which will be inserted into the database.

I've tried:
Expand|Select|Wrap|Line Numbers
  1. Elements links ="span.messageBody");
  2. for (Element link : links) {
  3.      message = link.text();
  4.      // codes to insert into DB
  5. }
but it doesn't work. Please help.
Mar 17 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.