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?

1
  • 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-sourced 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. Commented May 13, 2013 at 14:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.