Is there any StAX implementation for Android?

I want to use the StAX API implementation on android 1.6 and above devices. Are there any implementations? I cannot use the jar file directly, as it gives problems with the inner class. If it is not available, is there a way to recompile the implementation? Is there an alternative way to map the POJO class to XML and vice versa, excluding the SAX parser and the DOM parser.

I think the POJO class can be mapped to XML and vice versa using JAXB. But the situation is like this. Consider this example

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <cars> <car registration="abc123"> <brand>BMW</brand> <description>Sedan</description> </car> <car registration="abc123"> <brand>Ferrari</brand> <description>SportsCar</description> </car> </cars> 

Now, as a result, I want a List that has 2 cars.

Also, how does a JAXB parser pay against StAX?

+6
source share
2 answers

So you really want to "map POJOs in XML and vice versa" A simple XML library . You can use it with every version of Android from 1.5 to.

I even wrote a post explaining how to include it in one of your projects .

+4
source

As far as I know, Woodstox and Aalto should work on Android. Aalto is the fastest consistent XML parser on the Java platform, if that matters; and Woodstox supports a wide range of XML constructs (from full DTD processing to RelaxNG / XML Schema validation).

To bind POJOs to XML, you can also consider the Jackson jackson-xml-databind extension: while Jackson is mostly a JSON processor, the extension supports JAXB-style data binding for XML. And it does it faster than the JAXB reference implementation (see jvm-serializers test). This should also work on Android (Jackson himself is a JSON parser nr 1 on Android).

+8
source

Source: https://habr.com/ru/post/886347/


All Articles