Re: [Simple-support] Problem parsing attribute
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2011-04-29 11:52:43
|
Hi, This needs to be optional, its missing from the second element. @Attribute(name="Gesamt", required=false) public String gesamt; --- On Thu, 28/4/11, Dirk Dinger <dir...@vm...> wrote: From: Dirk Dinger <dir...@vm...> Subject: [Simple-support] Problem parsing attribute To: sim...@li... Received: Thursday, 28 April, 2011, 5:39 AM 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 -----Inline Attachment Follows----- ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd -----Inline Attachment Follows----- _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |