Correct way to parse XML using Simple Framework



I'm using Simple framework to deserialize an xml on my android app .


The issue is on a portion of the xml because I can get the objects of the other portions of it .


Here is the part of the xml that I struggle with :



<webtv name="channelname" date="2014-10-31">
<config>
<pathVideo extension="mp4">http://ift.tt/1GeY4c8;
<pathBigImage extension="jpg">http://ift.tt/1GeY4ca;
<pathImage extension="jpg">http://ift.tt/1GeY2AS;
<pays>GB;IE</pays>
</config>


Here is my XmlMapper class :


@Root(name="webtv", strict = false)



public class XmlModelMapper {

public ConfigObject getConfigObjects() {
return configObjects;
}

@Element(name="config")
public ConfigObject configObjects = new ConfigObject();


@ElementList(name = "itemList")
private List<Videos> itemList = new ArrayList<Videos>();
public List<Videos> getItemList() {
return itemList;
}

@ElementList(name = "chaineList")
private List<Chaine> chaineList = new ArrayList<Chaine>();
public List<Chaine> getChaineList() {
return chaineList;
}


}


If I change my mapper class to this :



@Root(name="webtv", strict = false)

public class XmlModelMapper {

public List<ConfigObject> getConfigObjects() {
return configObjects;
}

@ElementList(name="config")
public List<ConfigObject> configObjects = new ArrayList<ConfigObject>();


@ElementList(name = "itemList")
private List<Videos> itemList = new ArrayList<Videos>();
public List<Videos> getItemList() {
return itemList;
}

@ElementList(name = "chaineList")
private List<Chaine> chaineList = new ArrayList<Chaine>();
public List<Chaine> getChaineList() {
return chaineList;
}


}


and the log the size of the List I get 4 which is correct , but how to get each object in a distinct way including the extension (attribute)


Please help me solving this issue .


Thanks


No comments:

Post a Comment