I have an Rss feed that I'd like to parse in Java using Simple Framework. I have problems with 2 elements with the same name, but one of them has a namespace assigned. Here is an example xml:
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/">
<item>
<title>Regular Titel</title>
<dc:title>Dc Titel</dc:title>
</item>
</rss>
Currently my Item.class looks like this:
@Root
public class Item {
@Namespace(reference = "http://purl.org/dc/elements/1.1/", prefix = "dc")
@Element(name="title")
public String dcTitle;
@Element
public String title;
}
This obviously causes a PersistenceException (Duplicate annotation of name 'title' on field 'title'....), but i don't really know how I should do this. Could someone please help me to figure this out!
UPDATE
Althought the solution works, I now have problems serializing the objects. The namespaces, that I declare, are not assigned to the elements in the output xml.
Try
Did you try this?