When I want to specify the attribute for XML element in java class with Xmappr annotations, I use @Attribute annotation, e.g:
exampleclass.java:
@Attribute("Code")
private String code;
And it is mapping the attribute Code for Brand element
Brand.xml:
<Brand Code="123">
<Description>Name</Description>
<BrandName>true</BrandName>
</Brand>
My task is to change the Xmappr annotations to BeanIO.
The single element(without attribute) I can map with @Field annotation, e.g:
@Field(xmlName="Description")
Private String description;
So the question is, how do I get the attribute Code to java class with BeanIO? Do I need to change xml to:
<Brand>
<BrandCode>123</BrandCode>
<Description>Name</Description>
<BrandName>true</BrandName>
</Brand>
and than use a @Field annotation on Code, or there is other way to do it?
You can use
Your code then becomes:
EDIT - expanding the answer
From the documentation:
And in