Solved

UTF-8 rendering problem in JTree with XML

Posted on 2010-09-03
7
639 Views
Last Modified: 2012-05-10
Hi everyone.

I have a problem that I can't figure out. I want to show a list of folder in a JTree. I download the list as an XML file from a server and have 2 issues when showing them in the tree.
1. Non latin char are not displayed correctly
2. Rendering in the node stops after special char (haven't tested them all but "&" char is a problem.

Here is an XML sample:
<?xml version="1.0" encoding="UTF-8"?>
<volumes>
  <volume>
    <path>/01_Lancôme</path>  //ô is displayed like oÌ,
  </volume>
  <volume>
    <path>/V&R</path>  //&R is not displayed at all
  </volume>
</volumes>

If I read it in a web browser, everything looks fine. I use the DefaultTreeCellRenderer and DefaultMutableTreeNode. Also when I print to System.out, it shows up correctly.

Any ideas?

Tx
0
Comment
Question by:__geof__
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33595843
0
 
LVL 6

Author Comment

by:__geof__
ID: 33595874
gurvinder372:
Quite right you are. I should have mentioned it but I actually escape the & in Java, if not, it doesn't parse at all.
But it doesn't help either. Either & nor &amp; displays correctly.
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33595900
did you tried jakarta commons?
http://www.javalobby.org/java/forums/t19288.html

Also mention the exception that you get
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 6

Author Comment

by:__geof__
ID: 33596140
didn't help :(
other ideas?
0
 
LVL 6

Author Comment

by:__geof__
ID: 33596716
OK. My bad. I had a wrong parsing in the toString method of the object in the node. But the UTF-8 problem is still the same. Non latin char are not displayed correctly. Some thoughts?
0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 33596753
0
 
LVL 6

Author Closing Comment

by:__geof__
ID: 33597343
OK. Found it. The client used to download the xml file was latin1 so I had to force it into UTF-8.

I give you some points as thanks for the help.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question