[Simple-support] Problem parsing Attribute
Brought to you by:
niallg
|
From: Dirk D. <dir...@vm...> - 2011-05-05 10:41:42
|
2011/5/1 Dirk Dinger <dir...@go...> > Hello SimpleXML Users !, > > Just started with SimpleXML on Android, since I have to consume a XML > defined by my customer from an android app. > I have problems to get the "Gesamt" attribute from the <Stellen> Element > deserialized, as shown in the XML example below > > <?xml version="1.0" encoding="UTF-8"?> > <Result xsi:noNamespaceSchemaLocation= > "http://services.odav.de/lehrstellenradar/result.xsd" xmlns:xsi=" > http://www.w3.org/2001/XMLSchema-instance"> > <Content> > <*Stellen Gesamt="30">* > <Stelle> > <id>74_4911</id> > <Typ>Lehrstelle</Typ> > <Anzahl>1</Anzahl> > <Beruf>Fahrzeuglackierer/in</Beruf> > <Fachrichtung>Keine Fachrichtung</Fachrichtung> > <Beginn>01.09.10</Beginn> > <Featured>0</Featured> > <Link> > http://www.hwk-muenchen.de/74,0,jobboarddetail.html?lcj_id=xxx</Link> > > </Stelle> > <Stelle> > <id>74_4910</id> > <Typ>Lehrstelle</Typ> > <Anzahl>1</Anzahl> > <Beruf>Karosserie- und Fahrzeugbaumechaniker/in</Beruf> > <Fachrichtung>Keine Fachrichtung</Fachrichtung> > <Beginn>01.09.10</Beginn> > <Featured>0</Featured> > <Link> > http://www.hwk-muenchen.de/74,0,jobboarddetail.html?lcj_id=xxx</Link> > > </Stelle> > </Stellen> > </Content> > </Result> > > I have defined the following classes to deserialize the result > > package de.vmapit.dto; > > @Root(strict=false) > public class GetRecentJobListResult { > > @Element(name="Content") > public Stellen content; > > } > > @Element(name="Stellen") > public class Stellen implements Serializable { > > @ElementList(name="Stellen") > public List<Stelle> stellen; > > @Attribute(name="Gesamt") > public String gesamt; > } > > > If I execute > > GetRecentJobListResult res = > serializer.read(GetRecentJobListResult.class, new File("stellen.xml"), > false); > > the following execption gets thrown: > > org.simpleframework.xml.core.ValueRequiredException: > Unable to satisfy @org.simpleframework.xml.Attribute(name=Gesamt, empty=, > required=true) on field 'gesamt' public java.lang.String > de.vmapit.dto.Stellen.gesamt for class de.vmapit.dto.Stellen at line 3 > > Can anyone tell me, what I do wrong ? > > Regards, > Dirk > |