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 3941772
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:34:58+00:00 2026-05-20T00:34:58+00:00

i am using JSOUP and I have html/text something like: <html><head><style type=text/css> </style></head> <body><div

  • 0

i am using JSOUP
and I have html/text something like:

<html><head><style type="text/css">
</style></head>
<body><div style="font-family:times new roman,new york,times,serif;font-size:14pt">first text<br><div><br></div><div style="font-family: times new roman,new york,times,serif; font-size: 14pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">one:</span></b> second text<br><b><span style="font-weight: bold;">two:</span></b> third text<br><b><span style="font-weight: bold;">three:</span></b> fourth text<br><b><span style="font-weight: bold;">five:</span></b> fifth text<br></font><br>

and I want to extract the first div that contains a text (the whole div)
to get an output like:

<div style="font-family:times new roman,new york,times,serif;font-size:14pt">first text<br></div>

and one more question is how to get the first html tag (in general) that contains a text meaning the first text maybe inside <p> or <span>

thanks in advance

  • 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-20T00:34:58+00:00Added an answer on May 20, 2026 at 12:34 am

    You can use a SAX styled HTML parser, like TagSoup.

    To do this, initialize the parser with an extended DefaultHandler to cache the last element visited in a local member variable, then detect when the first time the characters(...) method is called and print out the cached element and the text result.

    Look to http://sax.sourceforge.net/quickstart.html for some direction in how to setup the parser.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using JSoup to parse HTML response. I have multiple Div tags. I have
I have a swing application that read HTML pages using the following command String
I am using a HTML parser called Jsoup, to load and parse HTML files.
I'm using jsoup to scrape some HTML data and it's working out great. Now
After I made many changes to the HTML document using JSoup so what I
I've started using JSoup today to use for an android app so I have
I'm trying to parse some html using jsoup (1.3.3) in my android activity. When
I have been using JSoup to parse lyrics and it has been great until
i'm using JSoup to parse a webpage like this , and make it into
I'm trying to do something similar to: Jsoup: How to get all html between

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.