I am trying an example on writing a Custom Unmarshaller for java.util.List based on example 21 of JiBX package. Problem I am facing is when I give following xml it gives an error.
<directory>
<list size="4">
<entry key="38193">
<PNR>
<UpdateLevel>12</UpdateLevel>
</PNR>
</entry>
<entry key="38192">
<PNR>
<UpdateLevel>13</UpdateLevel>
</PNR>
</entry>
</list>
</directory>
The exception I am getting is:
org.jibx.runtime.JiBXException: Expected "list" start tag, found "directory" start tag (line 1, col 11)
at org.jibx.runtime.impl.UnmarshallingContext.throwStartTagNameError(UnmarshallingContext.java:293)
at org.jibx.starter.CustomList.unmarshal(CustomList.java:69)
at org.jibx.starter.Test.main(Test.java:47)
but when I give input xml as follows:
<list size="4">
<entry key="38193">
<PNR>
<UpdateLevel>12</UpdateLevel>
</PNR>
</entry>
<entry key="38192">
<PNR>
<UpdateLevel>13</UpdateLevel>
</PNR>
</entry>
</list>
It works fine. Why it is not identifying the root element "directory" ?