EntityUtils.toString returns a strange string of characters

I am trying to parse an xml file online, but there seems to be something wrong with the way the data is displayed on the website on which I am trying to get it.

This is my method to return a website string;

 public String getXmlFromUrl(String url) {
    String xml = null;

    try {
        // defaultHttpClient
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);

        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();
        xml = EntityUtils.toString(httpEntity);

    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // return XML
    return xml;
}

When I debug the code, the line xmlfor the requested link returns this;

enter image description here

The link in the image above is a link, so I saved the data from this site to my own XML file and downloaded it here and if I used this link it would work fine, but using the "cloud" link in my picture, it returns these weird characters, does anyone know why?

+3
source share
1 answer

"UTF-8" :

xml = EntityUtils.toString(httpEntity, "UTF-8");
0

All Articles