2

In Java we can use tools like JAXB to do class-object mapping automatically for us, however in GWT, JAXB is not available as reflection is limited. the only way to it is :

Document messageDom = XMLParser.parse(messageXml);
Node rootNode = messageDom.getElementsByTagName("root").item(0);
String name = ((Element)fromNode).getAttribute("name");
...

Piriti looks good, but it lacks Android support, any other options?

Alaa Murad
  • 166
  • 1
  • 3
  • Side note: as long as you keep your JAXB marshalling/unmarshalling logic server-side, you can very well share the generated classes between client and server (if you are using JAXB this way). If you use GWT-RPC you need to put JAXB annotations sources into a `super-source`d client package and let all your generated classes implement the `Serializable` interface. If you use RequestFactory you will have client-side proxies for your server-side generated classes (to put it simply). All the above assumes you want to share a graph of objects out from an XML definition. – Andrea Boscolo May 13 '13 at 14:25

0 Answers0