5

My problem is that I have to parse HTML data like

84 101 <br>some text<br><table border='1'>Here comes a table definition</table>

and an XmlPullParserException is thrown on the following:

while (eventType != XmlPullParser.END_DOCUMENT) {
    if (eventType == XmlPullParser.START_TAG) {
        // do something
    } else if (eventType == XmlPullParser.END_TAG) {
        // do something else 
    }

    eventType = xpp.next(); // the XmlPullParserException is thrown here, on method next()
}

And the very interesting and strange part is this: the exception is thrown only on a Nexus S (OS version 4.0.4), on devices with lower OS version, this method works well.

The error message is the following:

org.xmlpull.v1.XmlPullParserException: Unexpected token (position:TEXT 84 101 @1:8 in java.io.StringReader@414e3248)

Can anyone explain me why is this happening only on ICS? Thanks.

overbet13
  • 1,654
  • 1
  • 20
  • 36

2 Answers2

0

1) Character encoding: Are you using different encodings with Nexus S? Is your file decoded in ANSI or utf? Compare it with your Nexus S encoding.

2) Charset: Are you using different charsets in your XML file. For example, are you using any chinese characters? What is the default in Nexus S?

These are the first two things to check.

Erol
  • 6,478
  • 5
  • 41
  • 55
  • Both the character encoding and the charset is the same. I think it is an OS issue. – overbet13 Aug 20 '12 at 09:27
  • Hi! @Erol I'm using chinese characters in the XML file. Any way I can resolve the problem without deleting those Chinese characters? – Wei Yang Dec 05 '13 at 05:59
0

Use CDATA for your html tags as

Everything inside a CDATA section is ignored by the parser.

A CDATA section starts with "<![CDATA[" and ends with "]]>"

Ajay Kumar Meher
  • 1,932
  • 16
  • 24