Parsing XML feed die with “Element is already used”

后端 未结 3 824
没有蜡笔的小新
没有蜡笔的小新 2020-12-10 12:08

I\'m trying to parse an XML feed using SimpleXML in Android: http://backend.deviantart.com/rss.xml?type=deviation&q=by%3Aspyed+sort%3Atime+meta%3Aall

Sample here

相关标签:
3条回答
  • 2020-12-10 12:55

    It appears that using

    @Element(name = "title", required = false, inLine=true)
    public String title = "";
    

    will solve your problem, as shown here.

    0 讨论(0)
  • 2020-12-10 12:58

    This fixes the problem:

    Remove this:

    @Element(name = "title", required = false)
    

    Replace with:

    //inside the inner class RssItem
    @Path("title")
    @Text(required=false)
    public String title = "";
    

    This should be repeated for any other field that gets the exception.

    0 讨论(0)
  • 2020-12-10 12:59

    There are two title elements in your XML file. The first title element is in channel tag and the other title element is in item tag. so you should specify to the parser that the paths for these titles are different. do that in the following way:

    Edit this:

    @Element(name = "title", required = false)
    public String title = "";
    

    Add Path Annotation:

    @Element(name = "title", required = false)
    @Path('rss/channel')
    public String title = "";
    

    here you specified for the title in channel tag that this is your path. the other title differs from you :)

    0 讨论(0)
提交回复
热议问题