元素也是class中的路径名

Element is also a path name in class

我正在尝试解析这个 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;
    }
}

但是我收到这个错误:

Element 'result' is also a path name in class nl.minerall.sapphire.lib.telegrams.ToteAddedTelegram

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

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