问题描述:

I am trying to deal with some XML that redefines itself as a child. By this I mean I have the following XML fragment:

<ns4:Warning>

<ns4:Symptom DTCList="2~3~600E18~C2797~NONE" sortOrder="5460">

<ns4:Symptom>Symptom description ...</ns4:Symptom>

</ns4:Symptom>

</<ns4:Warning>

I am receiving the following error from 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

Warning class:

@Root(name = "Warning")

public class Warning {

@Element(name = "Symptom") SymptomNS4 symptom;

}

SymptomNS4 class:

@Root(name = "Symptom")

public class SymptomNS4 {

@Attribute(name = "DTCList") String dtcList;

@Attribute(name = "sortOrder") String sortOrder;

@Element(name = "Symptom") String symptom;

}

Obviously, the approach I took is not working. How do you model this chunk of XML in SimpleXML?

相关阅读:
Top