Search code examples
javajsoup

Get title attribute with jsoup


I have a problem with parsing a website. The website contains a phrase like this:

<td class="school">
<abbr title data-original-title="Highschool">...</abbr>
</td>

How can I get the title (Highschool)? I'm programming with jsoup and java. Thanks for your help.


Solution

  • Just try reading jsoup cookbook.

    First you should get abbr element, and then its data-original-title attribute:

    Element abbrElement = doc.select("abbr").first();
    String originalTitle = abbrElement.attr("data-original-title");
    

    Of course you should make sure that you select right abbr element. Above code will select the first one appearing in the document.