Hi, two months ago I migrated from DOM parsing to using the pull parser. I did this to be more memory efficient. It wasn't absolutely necessary though and I currently think about re-writing my code to use DOM (or maybe SAX directly) again.
The reason is that I see phenomena that I can't explain ... I will show two of them below. I am wondering what your experience with the KXML pull parser is? I found this: >>XML Conformance In order to keep kXML as small as possible, no efforts are made to recognize certain well-formedness errors that would require additional detection code, such as - ']]>' contained in text content, - duplicate attributes, and - <? folowed by a space before the target. Thus, kXML will accept some XML documents that should actually be rejected. Of course, an XML parser should detect all syntax errors to discourage the creation of bogous documents that work with one parser and do not work with another. Thus, if you are not limited by memory constraints, please use MXP<http://www.extreme.indiana.edu/xgws/xsoap/xpp/mxp1/>, which is also faster than kXML.<< on their website (http://kxml.sourceforge.net/about.shtml) and meanwhile got the feeling that I am backing the wrong horse. Ok, here are the sample problems. My synchronization service reads an atom feed in UTF-8 from the Google Reader service. Some of my users use Japanese and Chinese charsets, but the atom feed from Google is still UTF-8. Ok? So I use something like this to parse the input stream from Google: XmlPullParser xpp = newPullParser(); xpp.setInput(myInputStream, "UTF-8"); So assuming that the Google Reader Service does it right and translates to UTF-8, then it is likely a bug (in a probably not the common use case) in KXML that I still get an IllegalArgumentException [1] deep in the KXML parser. I think an IAE, like an NPE, are developer's errors. So if it would be thrown by a method I call directly then my call would be wrong, but as it is deep in the parser, it's probably not me who caused the problem. The other problem I have is "org.xmlpull.v1.XmlPullParserException: expected: /summary read: entry (position:END_TAG </entry>" [2] ... which seem to happen infrequently, but still often enough that I recently got a bad comment about that in the Android Market. So if this error message was right it would mean that the Google Reader Service did *NOT* return a well formed document. I would consider that unlikely. Also I used the same URL later on by hand and the document I got back was well formed. And then there is this error message: " org.xmlpull.v1.XmlPullParserException: Illegal: ]]> (position:START_TAG <category term='user/13669348693970461925/state/com.google/fresh'>@328:892 in java.io.inputstreamrea...@431c4590)" ... I am not sure yet what to do about it. I am currently trying to get the actual XML from the user where this happened. I suspect I ran into one of the restrictions of the KXML parser. Maybe it's all my fault, which would be the easiest way out as I could fix it then. But then, where did I go wrong? Otherwise I'll have to go back to DOM. It would be good in that case if http://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.htmlwould warn that this parser is just for simple XML documents. Cheers, Mariano [1] D/SynchronizationService( 1389): Caught throwable. D/SynchronizationService( 1389): java.lang.IllegalArgumentException D/SynchronizationService( 1389): at java.nio.Buffer.position(Buffer.java:269) D/SynchronizationService( 1389): at com.ibm.icu4jni.charset.CharsetDecoderICU.setPosition(CharsetDecoderICU.java:335) D/SynchronizationService( 1389): at com.ibm.icu4jni.charset.CharsetDecoderICU.decodeLoop(CharsetDecoderICU.java:261) D/SynchronizationService( 1389): at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:375) D/SynchronizationService( 1389): at java.io.InputStreamReader.read(InputStreamReader.java:420) D/SynchronizationService( 1389): at org.kxml2.io.KXmlParser.peek(KXmlParser.java:874) D/SynchronizationService( 1389): at org.kxml2.io.KXmlParser.pushText(KXmlParser.java:824) D/SynchronizationService( 1389): at org.kxml2.io.KXmlParser.nextImpl(KXmlParser.java:323) D/SynchronizationService( 1389): at org.kxml2.io.KXmlParser.next(KXmlParser.java:1328) D/SynchronizationService( 1389): at com.newsrob.EntriesRetriever.fetchNewEntries(EntriesRetriever.java:476) D/SynchronizationService( 1389): at com.newsrob.SynchronizationService$4.run(SynchronizationService.java:170) D/SynchronizationService( 1389): at com.newsrob.SynchronizationService.doSync(SynchronizationService.java:343) D/SynchronizationService( 1389): at com.newsrob.SynchronizationService.access$0(SynchronizationService.java:84) D/SynchronizationService( 1389): at com.newsrob.SynchronizationService$1.run(SynchronizationService.java:73) D/SynchronizationService( 1389): at java.lang.Thread.run(Thread.java:935) D/SynchronizationService( 1389): Stashing it. [2] D/SynchronizationService( 2692): org.xmlpull.v1.XmlPullParserException: expected: /summary read: entry (position:END_TAG </entry>@94:533 in java.io.inputstreamrea...@43523880) D/SynchronizationService( 2692): at org.kxml2.io.KXmlParser.exception(KXmlParser.java:243) D/SynchronizationService( 2692): at org.kxml2.io.KXmlParser.error(KXmlParser.java:239) D/SynchronizationService( 2692): at org.kxml2.io.KXmlParser.parseEndTag(KXmlParser.java:531) D/SynchronizationService( 2692): at org.kxml2.io.KXmlParser.nextImpl(KXmlParser.java:316) D/SynchronizationService( 2692): at org.kxml2.io.KXmlParser.next(KXmlParser.java:1328) D/SynchronizationService( 2692): at com.newsrob.EntriesRetriever.fetchNewEntries(EntriesRetriever.java:481) D/SynchronizationService( 2692): at com.newsrob.SynchronizationService$4.run(SynchronizationService.java:169) D/SynchronizationService( 2692): at com.newsrob.SynchronizationService.doSync(SynchronizationService.java:334) D/SynchronizationService( 2692): at com.newsrob.SynchronizationService.access$0(SynchronizationService.java:83) D/SynchronizationService( 2692): at com.newsrob.SynchronizationService$1.run(SynchronizationService.java:72) D/SynchronizationService( 2692): at java.lang.Thread.run(Thread.java:935) [3] D/SynchronizationService( 984): org.xmlpull.v1.XmlPullParserException: Illegal: ]]> (position:START_TAG <category term='user/13669348693970461925/state/com.google/fresh'>@328:892 in java.io.inputstreamrea...@431c4590) D/SynchronizationService( 984): at org.kxml2.io.KXmlParser.exception(KXmlParser.java:243) D/SynchronizationService( 984): at org.kxml2.io.KXmlParser.error(KXmlParser.java:239) D/SynchronizationService( 984): at org.kxml2.io.KXmlParser.pushText(KXmlParser.java:817) D/SynchronizationService( 984): at org.kxml2.io.KXmlParser.parseStartTag(KXmlParser.java:678) D/SynchronizationService( 984): at org.kxml2.io.KXmlParser.nextImpl(KXmlParser.java:312) D/SynchronizationService( 984): at org.kxml2.io.KXmlParser.next(KXmlParser.java:1328) D/SynchronizationService( 984): at com.newsrob.EntriesRetriever.fetchNewEntries(EntriesRetriever.java:479) D/SynchronizationService( 984): at com.newsrob.SynchronizationService$4.run(SynchronizationService.java:169) D/SynchronizationService( 984): at com.newsrob.SynchronizationService.doSync(SynchronizationService.java:334) D/SynchronizationService( 984): at com.newsrob.SynchronizationService.access$0(SynchronizationService.java:83) D/SynchronizationService( 984): at com.newsrob.SynchronizationService$1.run(SynchronizationService.java:72) D/SynchronizationService( 984): at java.lang.Thread.run(Thread.java:935) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---