I'm trying to parse out a response from the Picasa API which is returned in XML and I'm using Simple XML Framework to do so. I've gotten most of it down except for an issue with namespaces. In the response, there are three id elements, you can see the partial xml below:
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:gphoto="http://schemas.google.com/photos/2007" <id>https://picasaweb.google.com/data/feed/user/11449325...</id> <entry gd:etag=""YD4qeyI.""> <id>https://picasaweb.google.com/data/entry/user/11449325.../albumid/10000004...</id> <gphoto:id>1000000...</gphoto:id> </entry> <entry gd:etag=""YD4qeyI.""> <id>https://picasaweb.google.com/data/entry/user/11449325.../albumid/10000004...</id> <gphoto:id>1000000...</gphoto:id> </entry> ... My object code is:
@Root(name = "feed", strict=false) public class PicasaResponse { @ElementList(name = "entry", inline = true) private List<Album> albums; public PicasaResponse() { } public List<Album> getAlbums() { return albums; } } @Root (name = "entry", strict = false) @NamespaceList({ @Namespace(reference="http://www.w3.org/2005/Atom"), @Namespace(reference="http://schemas.google.com/photos/2007", prefix="gphoto")}) class Album { @Element @Namespace(reference = "http://schemas.google.com/photos/2007") private String id; But I keep getting
Caused by: org.simpleframework.xml.core.PersistenceException: Element 'id' is already used with @org.simpleframework.xml.Element(data=false, name=, required=true, type=void) on field 'id' private java.lang.String com.companionfree.photoframe.Album.id at line 1 I've tried various ways of doing it and looked at the docs but they aren't any help. What am I doing wrong with my namespaces?
Note: I'm interested in collecting the "gphoto:id" information only.
No comments:
Post a Comment