ngallagher / simplexml

Simple XML
Apache License 2.0
97 stars 38 forks source link

Element 'Name' is already used with @org.simpleframework.xml.Element (etc) #35

Closed stodge closed 6 years ago

stodge commented 6 years ago

Don't ask me why (no, please don't!) but the XML I need to parse has:

<Name>
    <Name>Fred</Name>
</Name>

(The real field name has been changed to protect the innocent!)

Obviously, I'm getting the error:

Element 'Name' is already used with @org.simpleframework.xml.Element (etc)

My code is:

@Root(name = "Name", strict = false)
public class NameData {

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

Any ideas how to work around this? Thanks (Love the project BTW).

Kisty commented 6 years ago

Oh dear, I'm sorry to hear that you're faced with that problem and I take it the XML is out of your control. I can't think of a way off the top of my head, but my initial thought would be to try abl different XML parser, like Faster XML Jackson or something else. Or if your using Android, TikXml https://github.com/Tickaroo/tikxml is good.

I think development for this library is abandoned, unfortunately.

stodge commented 6 years ago

Thanks. Though I think I managed to get it working with the use of the following and some other tweaks:

@Root(strict = false)
@Path("Name")
@Text(required = false)
public class Name {