simplexml icon indicating copy to clipboard operation
simplexml copied to clipboard

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

Open magneticflux- opened this issue 6 years ago • 1 comments

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- avatar Dec 16 '17 00:12 magneticflux-

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)

magneticflux- avatar Dec 16 '17 00:12 magneticflux-