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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:32:26+00:00 2026-05-25T17:32:26+00:00

I am using jsoup to parse a number of things. I am trying to

  • 0

I am using jsoup to parse a number of things.

I am trying to parse this tag

<pre>HEllo Worl<pre>

But just cant get it to work.

How would i parse this using jsoup?\

    Document jsDoc = null;
     jsDoc = Jsoup.connect(url).get();
 Elements titleElements = jsDoc.getElementsByTag("pre");

Here is what i have so far.

  • 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-25T17:32:26+00:00Added an answer on May 25, 2026 at 5:32 pm

    Works fine for me with latest Jsoup:

    String html = "<p>lorem ipsum</p><pre>Hello World</pre><p>dolor sit amet</p>";
    Document document = Jsoup.parse(html);
    Elements pres = document.select("pre");
    
    for (Element pre : pres) {
        System.out.println(pre.text());
    }
    

    Result:

    Hello World

    If you get nothing, then the HTML which you’re parsing simply doesn’t contain any <pre> element. Check it yourself by

    System.out.println(document.html());
    

    Perhaps the URL is wrong. Perhaps there’s some JavaScript which alters the HTML DOM with new elements (Jsoup doesn’t interpret nor execute JS). Perhaps the site expects a real browser instead of a bot (change the user agent then). Perhaps the site requires a login (you’d need to maintain cookies). Who knows. You can figure this all out with a real webbrowser like Firefox or Chrome.

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

Sidebar

Related Questions

I am trying to parse this content using jsoup. <div class=imageInlineCenter style=width: 468px; align=center><img
i am trying to parse the title of this content using JSOUP.. <div class=article>
I'm trying to parse online dictionary results using Jsoup, of which I have a
I'm trying to parse some html using jsoup (1.3.3) in my android activity. When
I'm using Java and Jsoup to parse HTML pages and I want to get
i'm using JSoup to parse a webpage like this , and make it into
I have a problem when trying to parse a webpage using jSoup. If I
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
Im using JSoup to parse HTML response. I have multiple Div tags. I have

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.