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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:15:07+00:00 2026-05-19T03:15:07+00:00

I have a little sample program which extracts some information from an HTML document.

  • 0

I have a little sample program which extracts some information from an HTML document.

import org.jsoup.*;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

public class TestSoup {

    public static void main(String[] args) {

        String html = "<p>An <a href='http://example.com/'><b>exa&nbsp;mple</b></a> link.</p>";
        Document doc = Jsoup.parse(html);
        Element link = doc.select("a").first();

        String linkText = link.text(); // "example""
        System.out.println(linkText);

    }

}

If you’ve worked with jSOup you’ll know that the output of this should be exa mple but the output is exaámple. Why is jSoup not unescapting my HTML entities properly or am i simply doing this wrong?

All my HTML entities get unescaped incorrectly and not only &nbsp;

  • 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-19T03:15:08+00:00Added an answer on May 19, 2026 at 3:15 am

    jSoup works correctly, you have a problem with output encoding.

    In Windows, character encoding used by console (CP437 in your case) is not the same as the system encoding (Windows-1252 in your case). System.out.println() outputs your string in the system default encoding, therefore it’s incorrectly displayed in console.

    In Java 1.6 you can try System.console() instead:

    System.console().writer().println(linkText); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little sample application I was working on trying to get some
I've started working on a little ruby project that will have sample implementations of
This may be a little hard to describe since I don't have a sample.
I have little unusual problem to solve. I need some hint or links to
I have a program for some scientific simulation stuff, and as such needs to
I have googled some time now trying to find a good sample application that
I have some .gz compressed files which is around 5-7gig uncompressed. These are flatfiles.
Now I'm making a little program in Java which must read a really big
I have written a little program that parses log files of anywhere between a
I have a simple little command-line program, written in C#, running under .NET 4.0,

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.