ngallagher / simplexml

Simple XML
Apache License 2.0
97 stars 38 forks source link

Parse XML that has elements with the same name under different namespaces #30

Open magneticflux- opened 6 years ago

magneticflux- commented 6 years ago

When parsing RSS feeds, I run into an issue with the itunes namespace. I have a root with two elements: author and itunes:author, and I am unable to correctly parse them. I've tried specifying the namespace on the element itself and I've tried specifying the element path using @Path, but to no avail. Is functionality like this supported in SimpleXML?

magneticflux- commented 6 years ago

Here is the error that occurs when I only add an element for the first author:

Caused by: org.simpleframework.xml.core.PersistenceException: Element 'author' is already used with @org.simpleframework.xml.Element(data=false, name=author, required=true, type=void) on field 'author' private final java.lang.String org.x.y.z.a.b.Item.author at line 1

Here is the error that occurs when I add both elements, with the itunes one having a namespace declaration:

Caused by: org.simpleframework.xml.core.ConstructorException: Parameter 'author' is a duplicate in public org.x.y.z.a.b.Item(java.lang.String,java.lang.String,java.lang.String,java.lang.String,org.x.y.z.a.b.Guid,java.lang.String,org.x.y.z.a.b.Source)