I've got this xml:
<cars>
<a b="car" c="blue">
<x year="01"/>
<x year="03"/>
</a>
<a b="truck" c="red">
<x year="04"/>
<x year="85"/>
</a>
</cars>
And I want to parse to an object (arraylist) like this:
01:["car", "blue", "01, 03"]
02:["truck", "red", "04, 85"]
Notice that the two year atrributes goes together in the same String. That's what I can not figure out.
The parser I'm using is the android native XMLPullParser
I cannot change XML format but I could use another android compatible parser if it's worth it.
If it's not clear it has to fit on an class like this:
private String car;
private String color;
private String years;
public ClassVehicle(String aCar, String c, String ys) {
this.orden = aCar;
this.intext = c;
this.lugar = ys;
}
getters & setters toString() and so on
the final result will as many arraylists(objects) as cars:
ArrayList<ClassCar> oCars = new ArrayList<ClassCar>();
oCars.add(new ClassCar(car, color, years));