Element does not have a match in class

和自甴很熟 提交于 2021-01-27 04:08:22

问题


I am working with Simple XML framework, and just renamed some XML layouts, which now don't seem to work any more.

This is my XML:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
  <orderListReply id="R000000000006">
    <order orderid="12" type="outbound" state="available">
       <todo>2</todo>
       <done>0</done>
       <lines>1</lines>
       <erporderid>0</erporderid>
    </order>
  </orderListReply>

And this is my code class definition:

@Root(name="orderListReply")
public class OrderListReplyTelegram extends Telegram {

    @ElementList(name="order", inline=true, required=false)
    private List<OrderListItem> orders;
    ...

This is the error I get:

org.simpleframework.xml.core.ElementException: Element 'order' does not have a match in class nl.minerall.sapphire.pocket.telegrams.OrderListReplyTelegram at line 1


回答1:


Unfortunately, debugging Simple XML Framework isn't easy, but some trial and error helped me.

My OrderListItem class had this header:

@Element(name="order")
public class OrderListItem {

when changed to this:

@Root(name="order")
public class OrderListItem {

it worked. Strange thing is, in other code, the @Element annotation seemed to work (this code comes from another, working, tree).



来源:https://stackoverflow.com/questions/29493840/element-does-not-have-a-match-in-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!