Note that there are some explanatory texts on larger screens.

plurals
  1. POSimpleXML: Element declared twice
    text
    copied!<p>I try to parse an xml with the <a href="http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#list" rel="nofollow noreferrer">SimpleXML</a> lib, and I'm getting the following exception; can't figure out why it's complaining when I have my waters defined as a list. Probably something very basic I'm overlooking, but I just can't find it. I'm pretty much following the pattern of the example given on <a href="http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#list" rel="nofollow noreferrer">http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#list</a></p> <p>btw: there's a <a href="https://stackoverflow.com/questions/5973028/simple-xml-element-declared-twice-error">similar question</a> here on StackOverflow, but it's a different case, not actually dealing with ElementLists. In my case, I definitely want an ElementList and therefore would assume, the multiple existance of my element should actually be ok.</p> <p>Error log:</p> <pre><code>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) .... </code></pre> <p>XML:</p> <pre><code>&lt;?xml version="1.0" ?&gt; &lt;gewaesser&gt; &lt;returncode&gt;0&lt;/returncode&gt; &lt;gewaessereintrag&gt; &lt;id&gt;1&lt;/id&gt; &lt;name&gt;&lt;![CDATA[Entry1]]&gt;&lt;/name&gt; &lt;info&gt;&lt;![CDATA[Info1.]]&gt;&lt;/info&gt; &lt;/gewaessereintrag&gt; &lt;gewaessereintrag&gt; &lt;id&gt;2&lt;/id&gt; &lt;name&gt;&lt;![CDATA[Entry2]]&gt;&lt;/name&gt; &lt;info&gt;&lt;![CDATA[Info2.]]&gt;&lt;/info&gt; &lt;/gewaessereintrag&gt; &lt;/gewaesser&gt; </code></pre> <p>WaterList (handling <code>&lt;gewaesser&gt;</code>):</p> <pre><code>@Root(name = "gewaesser") public class WaterList { @ElementList(type = Water.class, name = "gewaessereintrag") private List&lt;Water&gt; waters; @Element(name = "returncode") private String returncode; public List&lt;Water&gt; getWaters() { return waters; } } </code></pre> <p>Water (handling <code>&lt;gewaessereintrag&gt;</code>):</p> <pre><code>@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; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload