xml simple example

315 views
Skip to first unread message

Leonardo Battagli

unread,
Sep 24, 2013, 11:02:44 AM9/24/13
to bea...@googlegroups.com

hello

what if I want to parse an xml like this

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tag1 paymentItemId="145511">
<statusCode>200</statusCode>
<statusMsg>PaymentItem added</statusMsg>
<imgUrl>ddd</imgUrl>
<pItemUrl>dddd</pItemUrl>
<qrCode>AAEAAAACMkHn4s73</qrCode>
</tag1>

I'm using a mapping like this... but it doesn't work


  <stream name="tag1" format="xml" >    
    <record name="qrCodeData" class="example.QrCodeData">
      <field name="statusCode" />
      <field name="statusMsg" />
      <field name="imgUrl" />
      <field name="pItemUrl" />
      <field name="qrCode" />
    </record>
  </stream>
</beanio>

beanIo is looking for a record
Exception in thread "main" org.beanio.UnidentifiedRecordException: Unidentified record at line 3

the mapping above works if applied to this xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tag1 paymentItemId="145511">
<qrCodeData>
<statusCode>200</statusCode>
<statusMsg>PaymentItem added</statusMsg>
<imgUrl>ddd</imgUrl>
<pItemUrl>dddd</pItemUrl>
<qrCode>AAEAAAACMkHn4s73</qrCode>
<qrCodeData>
</tag1>

how can I change the mapping file to match to the first xml example

thks


Kevin

unread,
Sep 24, 2013, 10:17:07 PM9/24/13
to bea...@googlegroups.com
Hello,

If you are parsing a single document/record, your stream definition should look more like this:

  <stream name="tag1" format="xml" xmlType="none">    
    <record name="tag1" class="example.QrCodeData">
      <field name="statusCode" />
      <field name="statusMsg" />
      <field name="imgUrl" />
      <field name="pItemUrl" />
      <field name="qrCode" />
    </record>
  </stream>

Thanks,
Kevin

Leonardo Battagli

unread,
Oct 5, 2013, 4:11:46 PM10/5/13
to bea...@googlegroups.com
Thanks
It works !

Jasleen Kaur Pannu

unread,
Jan 22, 2019, 4:53:47 PM1/22/19
to beanio-users


Hi I am trying to parse XML file 

<?xml version="1.0" encoding="UTF-8"?>
 <root>
<record_Type_06>
<id>06</id>
<record_Action>A</record_Action>
<cTN></cTN>
<sID></sID>
<eventRecord>FY</eventRecord>
<circuitCourt></circuitCourt>
<eventDate></eventDate>
<eventTime></eventTime>
<eventAction></eventAction>
<judgeBar></judgeBar>
<defAttyBar></defAttyBar>
<location>01122018</location>
</record_Type_06>
<record_Type_07>
<id>07</id>
<record_Action>A</record_Action>
<cTN></cTN>
<sID></sID>
<status></status>
<bond></bond>
</record_Type_07>
<record_Type_08>
<id>08</id>
<record_Action></record_Action>
<cTN></cTN>
<sID></sID>
<count></count>
<authCharge></authCharge>
<authCharge></authCharge>
<finalCharge></finalCharge>
<finalz></finalz>
<dispo>/84</dispo>
<dispDate>/84</dispDate>
<dispEvent>/84</dispEvent>
<courtCount>/84</courtCount>
<notice>/84</notice>
</record_Type_08>

</root>

How should I do, can you please help with benaio 
Reply all
Reply to author
Forward
0 new messages