I'm developing android project which is based on Simple Framework. For some time I noticed that I must to implement dynamic parsing. In brief I have a big xml file downloaded from backend. This xml file can contains tags which can be different from time to time and unchangeable tags which are used by my application.
Let's say that I have this xml file:
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
<age>33</age>
</note>
And java model class
@Root(name="note", strict = false)
public class Note {
@Element(name = "to", required = false)
public String to;
@Element(name = "from", required = false)
public String from;
@Element(name = "heading", required = false)
public String heading;
@Element(name = "body", required = false)
public String body;
@Element(name = "age", required = false)
public int age;
//getters/setters...
}
but sometimes I can download xml which can looks like this (x1 - unknown name):
<note>
<x1>content...</x1>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<x2>content...</x2>
<body>Don't forget me this weekend!</body>
<age>33</age>
<x3>content...</x3>
<xN>content...</xN>
</note>
In that case when my app read/edit this xml and save to xml file to send back to backend there is no x1..xN tags because I don't known how to maintain them in my model.
My app is based on big model layer which contains that pojo classes so I need to find a solution where store this unknown tags.