Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7970609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:25:51+00:00 2026-06-04T07:25:51+00:00

I try to parse an xml with the SimpleXML lib, and I’m getting the

  • 0

I try to parse an xml with the SimpleXML 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 http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#list

btw: there’s a similar question 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.

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 (handling <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;
    }
}

Water (handling <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;

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:25:52+00:00Added an answer on June 4, 2026 at 7:25 am

    I just found the answer myself, but maybe this is helpful for others:

    I forgot to declare “inline = true“

    @ElementList(type = Water.class, name = "gewaessereintrag", inline = true)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Python code: import xml.dom.minidom import xml.parsers.expat try: domTree = ml.dom.minidom.parse(myXMLFileName)
I'm try to parse this xml, but c# keeps throwing an exception saying it
I have a xml file which contains arabic characters.When i try to parse a
Xml parsing api is throwing sax parse exception, If i try to parse a
Newbie to C# here.... I have the following code: var xdoc = XDocument.Parse(xml); var
I have the following XML document that I have to parse using python's minidom:
I have a problem when I try to parse a xml file containing a
try{Integer.parse(Abhishek);} catch(NumberFormatException e){} catch(Exception e){} If for the above piece of code, if NumberFormatException
I try to parse RSS chaanal with simple-rss lib. Unfortunately I got a lot
I have a JSON which I get from web application. I try this parse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.