The item does not have a match in the class.

I work with a simple XML structure and just renamed some XML layouts that now seem to no longer work.

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 the definition of my code:

 @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: The 'order' element does not match in the class nl.minerall.sapphire.pocket.telegrams.OrderListReplyTelegram on line 1

+6
source share
1 answer

Unfortunately, debugging the Simple XML Framework is not easy, but some trial versions and errors helped me.

In my OrderListItem class OrderListItem was this header:

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

when changing to this:

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

it worked. The strange thing is, in another code, the @Element annotation seemed to work (this code comes from a different, working, tree).

+4
source

Source: https://habr.com/ru/post/984793/


All Articles