Android - 简单 - xml重复注释错误

时间:2016-04-17 00:29:55

标签: android xml rss retrofit2 simple-framework

我正在尝试解密并将其实施到我的应用中的this RSS Feed。 尝试这样做时,我遇到了下一个错误:

 java.lang.RuntimeException: org.simpleframework.xml.core.PersistenceException: Duplicate annotation of name 'title' on method 'title'

如果你想检查xml RSS提要我试图破译你会发现两者 - “频道”和“项目”都有“标题”属性没有前缀来区分这两者因此我得到了以前的提到的错误。

有什么想法吗?

以下是课程:

Rss -

@Root
public class Rss
{
    @Element
    private Channel channel;

    @Attribute
    private double version;

    public Channel getChannel ()
    {
        return channel;
    }

    public void setChannel (Channel channel)
    {
        this.channel = channel;
    }

    public double getVersion ()
    {
        return version;
    }

    public void setVersion (double version)
    {
        this.version = version;
    }

    @Override
    public String toString()
    {
        return "ClassPojo [channel = "+channel+", version = "+version+"]";
    }
}

频道 -

public class Channel
{

    @Attribute
    @Path("Channel")
    private String title;

    @Attribute
    private String description;

    @Attribute
    private String link;

    @Attribute
    private String lastBuildDate;

    @ElementList
    private List<Item> item;

    @Attribute
    private String language;

    @Attribute
    public String getTitle ()
    {
        return title;
    }

    public void setTitle (String title)
    {
        this.title = title;
    }

    public String getDescription ()
    {
        return description;
    }

    public void setDescription (String description)
    {
        this.description = description;
    }

    public String getLink ()
    {
        return link;
    }

    public void setLink (String link)
    {
        this.link = link;
    }

    public String getLastBuildDate ()
    {
        return lastBuildDate;
    }

    public void setLastBuildDate (String lastBuildDate)
    {
        this.lastBuildDate = lastBuildDate;
    }

    public List<Item> getItem ()
    {
        return item;
    }

    public void setItem (List<Item> item)
    {
        this.item = item;
    }

    public String getLanguage ()
    {
        return language;
    }

    public void setLanguage (String language)
    {
        this.language = language;
    }

    @Override
    public String toString()
    {
        return "ClassPojo [title = "+title+", description = "+description+", link = "+link+", lastBuildDate = "+lastBuildDate+", item = "+item+", language = "+language+"]";
    }
}

项目 -

public class Item
{
    @Element
    private Guid guid;

    @Attribute
    private String pubDate;

    @Attribute
    private String author;

    @Attribute
    private String title;

    @ElementList
    private List<String> category;

    @Element
    private Enclosure enclosure;

    @Attribute
    private String description;

    @Attribute
    private String link;

    public Guid getGuid ()
    {
        return guid;
    }

    public void setGuid (Guid guid)
    {
        this.guid = guid;
    }

    public String getPubDate ()
    {
        return pubDate;
    }

    public void setPubDate (String pubDate)
    {
        this.pubDate = pubDate;
    }

    public String getAuthor ()
    {
        return author;
    }

    public void setAuthor (String author)
    {
        this.author = author;
    }

    public String getTitle ()
    {
        return title;
    }

    public void setTitle (String title)
    {
        this.title = title;
    }

    public List<String> getCategory ()
    {
        return category;
    }

    public void setCategory (List<String> category)
    {
        this.category = category;
    }

    public Enclosure getEnclosure ()
    {
        return enclosure;
    }

    public void setEnclosure (Enclosure enclosure)
    {
        this.enclosure = enclosure;
    }

    public String getDescription ()
    {
        return description;
    }

    public void setDescription (String description)
    {
        this.description = description;
    }

    public String getLink ()
    {
        return link;
    }

    public void setLink (String link)
    {
        this.link = link;
    }

    @Override
    public String toString()
    {
        return "ClassPojo [guid = "+guid+", pubDate = "+pubDate+", author = "+author+", title = "+title+", category = "+category+", enclosure = "+enclosure+", description = "+description+", link = "+link+"]";
    }
}

指导 -

public class Guid
{
    private String content;

    private String isPermaLink;

    public String getContent ()
    {
        return content;
    }

    public void setContent (String content)
    {
        this.content = content;
    }

    public String getIsPermaLink ()
    {
        return isPermaLink;
    }

    public void setIsPermaLink (String isPermaLink)
    {
        this.isPermaLink = isPermaLink;
    }

    @Override
    public String toString()
    {
        return "ClassPojo [content = "+content+", isPermaLink = "+isPermaLink+"]";
    }
}

附件 -

public class Enclosure
{

    @Attribute
    private String type;

    @Attribute
    private String url;

    public String getType ()
    {
        return type;
    }

    public void setType (String type)
    {
        this.type = type;
    }

    public String getUrl ()
    {
        return url;
    }

    public void setUrl (String url)
    {
        this.url = url;
    }

    @Override
    public String toString()
    {
        return "ClassPojo [type = "+type+", url = "+url+"]";
    }
}

0 个答案:

没有答案