Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Element does not have a match in class

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

like image 861
Bart Friederichs Avatar asked Apr 07 '15 14:04

Bart Friederichs


1 Answers

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).

like image 131
Bart Friederichs Avatar answered Sep 23 '22 14:09

Bart Friederichs