SAXParser falha quando a resposta contém hindi ou outros caracteres especiais
Estou usando o analisador SAX para analisar uma resposta XML, mas gera uma exceçã
ExpatParser$ParseException : (not well formed) invalid token
Existe alguma solução?
Aqui está o meu código:
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setContentCharset(params, "UTF-8");
HttpPost postMethod = new HttpPost(MyRequestURL);
DefaultHttpClient hc = new DefaultHttpClient(params);
postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));
ResponseHandler <String> res = new BasicResponseHandler();
String response=hc.execute(postMethodURL,res);
ByteArrayInputStream byteArrayInputStream =
new ByteArrayInputStream(response.getBytes("UTF8"));
/* SAXParser from the SAXPArserFactory. */
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
/* Get the XMLReader of the SAXParser we created. */
XMLReader xr = sp.getXMLReader();
/* Create a new ContentHandler and apply it to the XML-Reader*/
MyHandler objHandler = new MyHandler();
xr.setContentHandler(objHandler);
InputSource inputSource = new InputSource(byteArrayInputStream);
inputSource.setEncoding("UTF-8");
/* Parse the xml-data from our URL. */
xr.parse(inputSource);
/* Parsing has finished. */