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?
Add @Root(strict=false)
to the Player
class. What's happening is that the Boxscore
class is not strict
but the Player
class is.
Also, the documentation states that: Also, elements within an element list, as represented by the ElementList annotation need this annotation so that the element names can be determined.
Since your Player
class is in an ElementList
it needs the @Root
annotation as well.