Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5957729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:26:34+00:00 2026-05-22T18:26:34+00:00

Using jsoup, I know how to extract the text of an entire div: <div

  • 0

Using jsoup, I know how to extract the text of an entire div:

<div class="c">
<a href="/relurl.php?refid=7">First Anchor Text</a>
 Something in Between 
 <a href="/john.doe?refid=7">Second Anchor Text</a>
</div>

Such that div.text() yields:

First Anchor Text Something in Between
Second Anchor Text

And I know how to extract the text of each anchor separately, such that the first a.text() yields:

First Anchor Text

But is there an elegant way in Jsoup to extract only Something in Between?

(I can of course extract the 2 a.text() and “subtract” them from div.text() but I don’t consider this elegant)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:26:35+00:00Added an answer on May 22, 2026 at 6:26 pm

    Use Element#ownText(). Here’s an extract from the linked javadoc:

    ownText

    public String ownText()
    

    Gets the text owned by this element only; does not get the combined text of all children.

    For example, given HTML <p>Hello <b>there</b> now!</p>, p.ownText() returns "Hello now!", whereas p.text() returns "Hello there now!". Note that the text within the b element is not returned, as it is not a direct child of the p element.

    So, this should do:

    String ownText = div.ownText();
    // ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Jsoup to extract URL of an webpage. The href attribute of
How do i get this text from the following html code using Jsoup? <h2
I'm creating a class using jsoup that will do the following: The constructor opens
Im using JSoup with android and so far I have been successful. In my
I am currently using Jsoup to parse a html. The code is quite simple:
i'm trying to open a page using JSoup . I've tried opening a page
Does anyone know of a URL to get your Skype status using JSONP? I've
hi friends i m using this tutorial http://xjaphx.wordpress.com/2012/02/04/android-xml-adventure-parsing-html-using-jsoup/ and after i implemented this code
I am using Jsoup. I do a get document= connect.get(); and get the html
I'm using Java and Jsoup to parse HTML pages and I want to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.