UTF-8 rendering problem in JTree with XML

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
LVL 6
__geof__Asked:
Who is Participating?
 
Gurvinder Pal SinghConnect With a Mentor Commented:
0
 
Gurvinder Pal SinghCommented:
0
 
__geof__Author Commented:
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
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
Gurvinder Pal SinghCommented:
did you tried jakarta commons?
http://www.javalobby.org/java/forums/t19288.html

Also mention the exception that you get
0
 
__geof__Author Commented:
didn't help :(
other ideas?
0
 
__geof__Author Commented:
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
 
__geof__Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.