问题
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