1

I've been working on an app that parses out the information available in the following feed:

http://www.tsn.ca/datafiles/xml/cfl/boxscores/1191818.xml

Everything was working fine until today. The feed changed to add in the TT attribute for some players...

<box-player table="receiving-data" team="1" name="Jeff|Fuller" REC="1" TT="0" YDS="21" TD="0" LNG="21">player</box-player>

and then simple started throwing TT is not specified or Attribute not listed exceptions( can't remember the "actual" name).

I made sure to add strict = false, for the root of the feed:

@Root(name = "boxscore", strict = false)
public class Boxscore 
{
   @Element(name = "file-info", required = false)
   private FileInfo fi;

   @Element(name = "away-team", required = false)
   private AwayTeam awayTeam;

   @Element(name = "home-team", required = false)
   private HomeTeam homeTeam;

   @Element(name = "stat-headings", required = false)
   private StatHeadings statHeadings;

   @Element(name = "qips", required = false)
   private Qips qips;

   @Element (name = "notes", required = false)
   private String notes;

   @ElementList(name = "players", required = false)
   private List<Player> anyPlayers;

   @ElementList(inline = true, required=false, entry = "box-player")
   private List<Player> inlinePlayers;

   public List<Player> getPlayers()
   {
    if(anyPlayers == null)
    {
        return inlinePlayers;
    }
    else return anyPlayers;
   }
   // other get methods ...
}

My declaration for the player class looks like - Here's an excerpt:

@Element(name= "box-player")
public class Player { ... }

I have tried to add strict = false for the @Element, but I get "The attribute strict is undefined for the annotation type Element".

Is there a way I can ignore newly added attributes? So parsing still works?

4

1 回答 1

2

添加@Root(strict=false)Player班级。发生的事情是Boxscore类不是strict,但Player类是。

此外,文档指出: 此外,元素列表中的元素(由 ElementList 注释表示)需要此注释,以便可以确定元素名称。

由于您的Player课程在其中,ElementList因此也需要@Root注释。

于 2013-08-07T19:23:29.683 回答