1

I'm developing a Java app, that calls a PHP from internet that it's giving me a XML response.

In the response is contained this word: "Próximo", but when i parse the nodes of the XML and obtain the response into a String variable, I'm receiving the word like this: "Próximo".

How can i solve this?

Pshemo
  • 122,468
  • 25
  • 185
  • 269
Pableras84
  • 1,195
  • 5
  • 18
  • 30
  • These are not rare characters, they are Spanish characters. – Cole Tobin Jul 15 '12 at 17:28
  • See http://stackoverflow.com/questions/994331/java-how-to-decode-html-character-entities-in-java-like-httputility-htmldecode – Sergey Eremin Jul 15 '12 at 17:30
  • Pableras84 is calling a php script not belonging to him from a java app or did i get it wrong? The question is tagged java – Sergey Eremin Jul 15 '12 at 17:33
  • What encoding are you using in PHP script and what in your Java app? Does that XML file generated by PHP look ok when you show it in browser? – Pshemo Jul 15 '12 at 17:51

3 Answers3

2

StringEscapeUtils.unescapeHTML()

Sergey Eremin
  • 10,994
  • 2
  • 38
  • 44
  • kdb, it's free to use that in a commercial app??? i must do something to use that? for example link to apache or something? – Pableras84 Jul 24 '12 at 06:25
0

Probably you are using different encoding in your Java app then encoding of PHP script. Try to set encoding of your stream, for example like that

URL oracle = new URL("http://www.yourpage.com/");
URLConnection yc = oracle.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
                        yc.getInputStream(),"utf-8"));//<-- here you set encoding
                                                     //to the same as in your PHP
String inputLine;
while ((inputLine = in.readLine()) != null) 
    System.out.println(inputLine);
Pshemo
  • 122,468
  • 25
  • 185
  • 269
0

I found solution to this problem... While parsing use "ISO-8859-1" format and use Html.fromHtml(string) method while storing your values into bean .Where "string" is the value inside the each tag of XML response.

crmm
  • 11
  • 4