Note that there are some explanatory texts on larger screens.

plurals
  1. POVery easy to solve issue with SimpleXML. What i'm doing wrong?
    primarykey
    data
    text
    <p>i'm working with Java and SimpleXML</p> <p>I need to parse this XML file with SimpleXML:</p> <pre><code>&lt;magazine title="N˙mero 1" id="1"&gt; &lt;description&gt;yutyutyu&lt;/description&gt; &lt;miniature&gt;http://web.com/scripts/getImage.php?idMagazine=1&amp;resource=miniature.jpg&lt;/miniature&gt; &lt;summary&gt;2&lt;/summary&gt; &lt;pages&gt; &lt;page src="http://web.com/scripts/getImage.php?idMagazine=1&amp;resource=page_001.jpg" id="1" thumbnail="http://web.com/scripts/getImage.php?idMagazine=1&amp;resource=thumbnail_001.jpg"&gt; &lt;areas&gt; &lt;area id="1"&gt; &lt;top&gt;188&lt;/top&gt; &lt;left&gt;204&lt;/left&gt; &lt;width&gt;399&lt;/width&gt; &lt;height&gt;319&lt;/height&gt; &lt;action type="openBrowser"&gt;http://www.web.com&lt;/action&gt; &lt;/area&gt; &lt;area id="2"&gt; &lt;top&gt;188&lt;/top&gt; &lt;left&gt;204&lt;/left&gt; &lt;width&gt;399&lt;/width&gt; &lt;height&gt;319&lt;/height&gt; &lt;action type="openBrowser"&gt;http://www.web.com&lt;/action&gt; &lt;/area&gt; &lt;/areas&gt; &lt;/page&gt; &lt;page src="http://web.com/scripts/getImage.php?idMagazine=1&amp;resource=page_002.jpg" id="2" thumbnail="web.com/scripts/getImage.php?idMagazine=1&amp;resource=thumbnail_002.jpg"/&gt; &lt;page src="http://web.com/scripts/getImage.php?idMagazine=1&amp;resource=page_003.jpg" id="3" thumbnail="web.com/scripts/getImage.php?idMagazine=1&amp;resource=thumbnail_003.jpg"/&gt; &lt;/pages&gt; &lt;/magazine&gt; </code></pre> <p>I'm getting this exception:</p> <blockquote> <p>03-22 16:02:35.072: WARN/System.err(1931): org.simpleframework.xml.core.ValueRequiredException: Unable to satisfy @org.simpleframework.xml.ElementList(data=false, empty=true, entry=, inline=false, name=, required=true, type=void) on field 'areas' public java.util.ArrayList com.Magazine.Page.areas for class com.Magazine.Page at line 1</p> </blockquote> <p>Magazine has an array of pages, and each page has an array of areas, and each area has a action class, wich has some more content. The problem must be on areas array, so it is in Page class.</p> <pre><code>@Root (name="magazine") public class FullMagazine { @Attribute String title; @Attribute String id; @Element String description; @Element String miniature; @Element int summary; @ElementList public ArrayList&lt;Page&gt; pages; public String getTitle() { return title; } public String getId() { return id; } public String getDescription() { return description; } public Bitmap getMiniature() { return Util.getRemoteBitmap(miniature); } public static FullMagazine Load(String xml){ Serializer serializer = new Persister(); try{ return serializer.read(FullMagazine.class, xml); }catch (Exception e) {e.printStackTrace();} return null; //si llega aquÌ es que ha fallado. } } </code></pre> <hr> <pre><code>@Root public class Page { @Attribute String src; @Attribute String id; @Attribute String thumbnail; @ElementList public ArrayList&lt;Area&gt; areas; } </code></pre> <hr> <pre><code>@Root public class Area { @Attribute String id; @Element int top; @Element int left; @Element int width; @Element int height; @Element Action action; } </code></pre> <hr> <pre><code>@Root public class Action { @Attribute String type; String action; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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