Android - 忽略元素的简单框架解析器?

Android - Simple framework parser to ignore elements?

我正在使用附加到 RetrofitSimpleXML。我的 XML 项目如下所示:

<item id="1-22-33-55" parentID="1" restricted="1">
        <res protocolInfo="http-get:*:video/mpeg:*">http://<blablahere>/slash/slash</res>
        <upnp:callSign>Channel</upnp:callSign>
        <upnp:channelID type="ANALOG">1</upnp:channelID>
        <upnp:channelID type="DIGITAL">1,0</upnp:channelID>
        <upnp:channelID type="SI">1,1019,10301</upnp:channelID>
        <upnp:channelID type="UNIVERSAL">578865282</upnp:channelID>
        <upnp:class>object.item.videoItem.videoBroadcast</upnp:class>
        <dc:title>Channel</dc:title>
    </item>

但是,我不想解析callSign。如果我 故意 从我的 POJO 中省略这个,我会得到异常:

org.simpleframework.xml.core.ElementException: Element 'callSign' does not have a match in class xxxxx.yyyyy.zzzzz.ContentDirectoryChannelItem at line 1

有没有办法指定在解析时具体忽略哪个元素?

我的 POJO:

public class ContentDirectoryChannelItem {

  @Attribute(name = "id")
  private String chanId;

  @Attribute(name = "parentID")
  private String parentID;

  @Attribute(name = "restricted")
  private String restricted;

  @ElementMap(entry = "channelID", key = "type", attribute = true, inline = true)
  private Map<String, String> channelIDmap;

  @Element(name = "class")// I want this out also !!!
  private String upnpClass;

  @Element(name = "title")
  private String dcTitle;

  @ElementMap(entry = "res", key = "protocolInfo", attribute = true, inline = true)
  private Map<String, String> resourceMap;
 }

谢谢,

我会回答我自己的问题。参考 http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#loosemap

我做了 2 处更改:

1).指定了所有应该有 strict = false.

@Root 元素
@Root(name = "item", strict = false)

2). Retrofit instance 转换器工厂已创建 nonStrict:

.addConverterFactory(SimpleXmlConverterFactory.createNonStrict())