SAXParser fails when responce contains Hindi or other special characters

前端 未结 5 813
遥遥无期
遥遥无期 2021-01-21 05:57

I am using SAX parser to parse a XML response but it throws an exception.

ExpatParser$ParseException : (not well formed) invalid token

Is there any

5条回答
  •  轮回少年
    2021-01-21 06:49

    I'm not entirely sure that it will solve your problem but I'd set the charset on the InputSource using its setEncoding() method.

    InputSource inputSource = new InputSource(byteArrayInputStream);
    inputSource.setEncoding("UTF-8");
    
    xr.parse(inputSource);
    

提交回复
热议问题