SimpleXML: element declared twice

I am trying to parse xml with the SimpleXML lib, and I am getting the following exception; cannot understand why he complains when my waters are defined as a list. Probably something very basic that I forget, but I just can not find it. I pretty much follow the example example provided at http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#list

btw: there is a similar question here on StackOverflow, but this is another case not dealing with ElementLists. In my case, I definitely want an ElementList, and therefore suggest that the multiple existence of my element should be fine.

Error Log:

Error parsing xml.
        org.simpleframework.xml.core.PersistenceException: Element 'gewaessereintrag' declared twice at line 9
        at org.simpleframework.xml.core.Variable$Adapter.read(Variable.java:456)
....

XML:

<?xml version="1.0" ?>
<gewaesser>
    <returncode>0</returncode>
    <gewaessereintrag>
        <id>1</id>
        <name><![CDATA[Entry1]]></name>
        <info><![CDATA[Info1.]]></info>
    </gewaessereintrag>
    <gewaessereintrag>
        <id>2</id>
        <name><![CDATA[Entry2]]></name>
        <info><![CDATA[Info2.]]></info>
    </gewaessereintrag>
</gewaesser>

WaterList (processing <gewaesser>):

@Root(name = "gewaesser")
public class WaterList {

    @ElementList(type = Water.class, name = "gewaessereintrag")
    private List<Water> waters;

    @Element(name = "returncode")
    private String returncode;

    public List<Water> getWaters() {
        return waters;
    }
}

( <gewaessereintrag>):

@Root(name = "gewaessereintrag")
public class Water {

    @Element(required = false, name = "name")
    private String name;

    @Element(required = false, name = "info")
    private String info;

    @Element(required = false, name = "id", type = Long.class)
    private Long id;

}
+3
1

, , , :

"inline = true"

@ElementList(type = Water.class, name = "gewaessereintrag", inline = true)
+4

All Articles