我的班级被注释为
@Root
public class Geonames {
@Path("intersection/street1")
@Element
public String street1;
@Path("intersection/highway1")
@Element
public String highway1;
@Path("intersection/street2")
@Element
public String street2;
@Path("intersection/highway2")
@Element
public String highway2;
@Path("intersection/lat")
@Element
public String lat;
@Path("intersection/lng")
@Element
public String lng;
@Path("intersection/distance")
@Element
public String distance;
}
XML是这样的:
<geonames>
<intersection>
<street1>11th Street</street1>
<highway1>residential</highway1>
<street2>Campbell Street</street2>
<highway2>unclassified</highway2>
<lat>37.8098123</lat>
<lng>-122.2969874</lng>
<distance>0.07</distance>
</intersection>
</geonames>
但我得到了错误:
05-26 23:46:46.511: E//RequestProcessor.java:250(23618): Caused by:
org.simpleframework.xml.core.ValueRequiredException: Unable to satisfy
@org.simpleframework.xml.Element(data=false, name=, required=true, type=void) on field
'street1' public java.lang.String com.mosier.securityapp.geonames.Geonames.street1 for
class com.mosier.securityapp.geonames.Geonames at line 4
这似乎表明 street1 没有价值,但它当然有。我的注释或类必须设置错误,但我对此太陌生,看不出发生了什么。我忽略了一个简单的解决方法吗?