我正在尝试处理一些重新定义为孩子的XML。我的意思是我有以下XML片段:
<ns4:Warning>
<ns4:Symptom DTCList="2~3~600E18~C2797~NONE" sortOrder="5460">
<ns4:Symptom>Symptom description ...</ns4:Symptom>
</ns4:Symptom>
</<ns4:Warning>
我从SimpleXML收到以下错误:
Element 'Symptom' is already used with @org.simpleframework.xml.Element(name=Symptom, data=false, type=void, required=false) on field 'symptom' com.foo.response.xml.SymptomNS4 com.foo.response.xml.Warning.symptom at line 1
警告类:
@Root(name = "Warning")
public class Warning {
@Element(name = "Symptom") SymptomNS4 symptom;
}
SymptomNS4课程:
@Root(name = "Symptom")
public class SymptomNS4 {
@Attribute(name = "DTCList") String dtcList;
@Attribute(name = "sortOrder") String sortOrder;
@Element(name = "Symptom") String symptom;
}
显然,我采取的方法不起作用。你如何在SimpleXML中模拟这块XML?