我正在尝试使用设置了松散映射标志的 Simple Xml Framework 解析部分 xml 文档,但出现异常。
XML:
<Body>
<TopGoalScorersResponse>
<TopGoalScorersResult>
<tTopGoalScorer>
<sName>Alan Dzagoev</sName>
<iGoals>3</iGoals>
<sCountry>Y</sCountry>
<sFlag>http://footballpool.dataaccess.eu/images/flags/ru.gif</sFlag>
<sFlagLarge>http://footballpool.dataaccess.eu/images/flags/ru.png</sFlagLarge>
</tTopGoalScorer>
</TopGoalScorersResult>
</TopGoalScorersResponse>
</Body>
爪哇:
TopGoalScorer topGoalScorer = serializer.read(TopGoalScorer.class, xml);
@Root(name="tTopGoalScorer", strict=false)
public class TopGoalScorer {
@Element(name="sName")
private String name;
@Element(name="iGoals")
private int numGoals;
@Element(name="sCountry")
private String country;
@Element(name="sFlag")
private String flagImageUrl;
}
例外:
06-22 14:11:46.530: E/Soap(2057): Unable to satisfy @org.simpleframework.xml.Element(data=false, name=sCountry, required=true, type=void) on field 'country' private java.lang.String uk.co.carr.david.TopGoalScorer.country for class uk.co.carr.david.TopGoalScorer at line 1
06-22 14:11:46.530: E/Soap(2057): org.simpleframework.xml.core.ValueRequiredException: Unable to satisfy @org.simpleframework.xml.Element(data=false, name=sCountry, required=true, type=void) on field 'country' private java.lang.String uk.co.carr.david.TopGoalScorer.country for class uk.co.carr.david.TopGoalScorer at line 1
有任何想法吗?任何帮助将不胜感激。
谢谢大卫