3

I would like to map the totalAmt tag in below xml file, both its value 100 and it's attribute Ccy.

<?xml version="1.0" encoding="UTF-8"?>
<transaction>
   <id>
       <eId>transactionId001</eId>
   </id>
   <amount>
       <totalAmt Ccy="XXX">100</totalAmt>
   </amount>
</transaction>

By reading BeanIO reference guide and posts here I got the impression that only one of them can be mapped.

So my question is: Can BeanIO handle this tag and could you show me how?

What I have tried and didn't work:

<segment name="amount">
    <field name="totalAmount" xmlName="totalAmt"></field>
    <field name="currency" xmlName="Ccy" xmlType="attribute"></field>
</segment>

2 Answers 2

4

Close, but you still need to add the segment element inside the segment tag to tell which field the attribute is belong to.

example.

<segment name="amount">
    <field name="totalAmount" xmlName="totalAmt"></field>
    <segment name="totalAmt">
        <field name="type" xmlName="Ccy" xmlType="attribute"></field>
    </segment>
</segment>
Sign up to request clarification or add additional context in comments.

2 Comments

It works! Something is wrong with my account, I can't upvote and choose this answer. It keeps saying something wrong with your request, try agin. Any body has ideas why?
good for you ;). Well, probably some error on SO. try logout, remove all cache and then try again
0

I am using bean io 2.1 version The

<segment name="totalAmt">
    <field name="totalAmount" xmlType="text"></field>  --->the bean variable "totalAmount" will give say 100 
    <field name="Cctype" xmlName="Ccy" xmlType="attribute" default="XXX"></field>    -->either set default value as XXX or it will take from cctype variable
</segment>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.