views:

289

answers:

1

I am trying to parse a RSS2.0 feed, obtained from a remote server, on my Android device using XML Pull Parser.

// get a parser instance and set input,encoding 
XmlPullParser parser = Xml.newPullParser();  
parser.setInput(getInputStream(), null);

I am getting invalid token exceptions after a few items have been parsed:

Error parsing document. (position:line -1, column -1) caused by: org.apache.harmony.xml.ExpatParser$ParseException: At line 158, column 25: not well-formed (invalid token)

Strangely, when I download the feed XML on the device, bundle it inside the raw folder and then run the same code. Everything works fine.

What could be the problem here? How do I validate the XML before I parse it on device?

[EDIT: If this is set: parser.setProperty(XmlPullParser.FEATURE_VALIDATION,true); parsing fails immediately] Thanks.

+3  A: 

I posted an answer to this in your other post: http://www.coderanch.com/t/495391/XML/Parsing-RSS-feeds-XML-Pull#2230731

Paul Clapham