【问题标题】:Element is also a path name in class元素也是类中的路径名
【发布时间】:2019-05-25 11:26:49
【问题描述】:

我正在尝试解析这个 XML:

<toteAdded id="R000000000012">
    <result code="S0000">Carrier added.</result>
</toteAdded>

使用此 Java 代码:

@Root(name="toteAdded")
public class ToteAddedTelegram extends Telegram {
    @Element
    String result;

    @Attribute
    @Path("result")
    private String code;

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return result;
    }
}

但我收到此错误:

元素 'result' 也是类 nl.minerall.sapphire.lib.telegrams.ToteAddedTelegram 中的路径名

【问题讨论】:

    标签: java android xml-parsing simple-framework


    【解决方案1】:

    您需要指定完整路径,否则会与元素名称Result冲突。

    @Attribute
    @Path("toteAdded/result")
    private String code;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-31
      • 1970-01-01
      • 2013-09-25
      • 2011-08-22
      相关资源
      最近更新 更多