Search code examples
javaandroidxmlsimple-framework

Parse XML into Java Object List using simpleframework


I have an xml like shown. I want to convert this document into equivalent Java object shown below

<page>
   <body>
    <category id="category-0_2">
        <container title="Spotlight" slug="spotlight"></container>
        <container title="Just Added Shows" slug="just_added_shows"></container>
        <container title="Originals" slug="originals"></container>
        <container title="Popular TV Shows" slug="popular_tv_shows"></container>
        <container title="Wonder Women" slug="wonder_women"></container>
    </category>
  </body>
</page>



public class HomeXML {
    Page page;
    Body body;
    Category category;
    List<Container> containerList;
}

Is it possible to do this using simpleframework xml serialiser? I can get the whole XML and parse it manually but I am looking for ways to do this via the simpleframework API.


Solution

  • Got the answer. simple framework provides utility functions which convert the XML document into Java object list.

    More details here http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#util