android parsing error on tablet but not emulator

2019-02-21 02:18发布

I have this exception:

org.xml.saxParseException: Unexpected token (position TEXT@1:2...)

but it is caused only when running my .apk on a tablet pc. The same data when is parsed on the android emulator never causes this exception and works 100%. Any ideas?

Here's the code that throws the exception:

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource inputSource = new InputSource();
inputSource.setCharacterStream(new StringReader(xmlData));
Document doc = db.parse(inputSource); 

And here is a part from the file:

<Results> <Result title="08 07 2011"><Field title="blah blah" value="blah blah" /> </Result></Results>

1条回答
戒情不戒烟
2楼-- · 2019-02-21 02:25

Default charset differs, maybe? Does the XML have a charset in it?

查看更多
登录 后发表回答