From email:
-----------------
On Thu, Jan 29, 2009 at 1:03 AM, Sean Sullivan wrote:
>
> The Android platform has a built-in XmlPullParser. However, Android
> does not include the
> org.xmlpull.mxp1.MXParser implementation class. Google provides some
> other (undocumented)
> implementation of the XmlPullParser interface.
>
> According to the Android SDK documentation, Android developers should
> use XmlPullParserFactory to
> instantiate a XmlPullParser object.
>
> My XStream patch enables XStream's XppDriver to operate correctly on
> Android. The patch uses
> XmlPullParserFactory to create the XmlPullParser object.
>
> Creating the MXParser class directly
>
> new MXParser()
>
> will not work on the Android platform. IMHO, the best approach is to
> use the XmlPullParserFactory
> to create the XmlPullParser object.
>
----------------
On Fri, Jan 30, 2009 at 3:27 AM, Jörg Schaible wrote:
>
> Hi Joe,
>
> On Mittwoch, 28. Januar 2009, Joe Walnes wrote:
>
>> I think Jörg was suggesting going the other way,
>
> no I didn't, but I was simply not aware of the role of XmlPullParserFactory. I
> always thought of Xpp3 as an own (properietary) library on its own, successor
> of kXML and predecessor of StAX.
>
>> and always calling
>> XmlPullParserFactory to create the parser (for both Android and
>> standard Java). This would simplify things and reduce the amount of
>> reflection required.
>>
>> I think that would work nicely.
>
> Definitely then.
>
>> Thanks for the patch Sean.
>>
>> -Joe
>>
>> Interesting coincidence of the day... I asked my friends on the
>> Android team which implementation of XmlPullParser was being used, and
>> they chose the open source kxml implementation (designed for mobile),
>> not knowing that the guy who wrote it (Stephan) works on the Google
>> mobile team in London, which is also the team I work on. Small world.
>
> Hehe.
>
> - Jörg
>
One small improvement on my patch:
Instead of Class.forName("xxxx"), XStream should use the Thread's context class loader:
ClassLoader cl = Thread.currentThread().getContextClassLoader();
cl.loadClass(className);