I have an Rss feed that I would like to parse in Java using the Simple Framework. I have problems with 2 elements with the same name, but one of them has a namespace. Here is an xml example:
<?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 is as follows:
@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 throws a PersistenceException (duplicating the annotation of the title "title" in the "title" field ....), but I really don't know how to do this. Can someone please help me figure this out!
UPDATE
Despite the fact that the solution works, I now have problems with serializing objects. The namespaces that I declare are not assigned to elements in the output xml file.