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
Java
Last Comment
__geof__
8/22/2022 - Mon
Gurvinder Pal Singh
i think chars like '&' should be mentioned as & to be displayed/parsed correctly
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 & displays correctly.
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?
http://www.javapractices.com/topic/TopicAction.do?Id=96
https://www.experts-exchange.com/questions/25010534/replacing-XML-Special-Characters.html