Skip to main content

@Xml(childName) Annotation

The @Xml(childName) annotation can be used to specify the name of XML child elements for bean properties of type collection or array.

Example
Data typeJSON exampleWithout annotationWith annotation
class MyBean {
@Xml(childName="X")
public String[] a;
@Xml(childName="Y")
public int[] b;
}
{
a: ['foo','bar'],
b: [123,456]
}
<object>
<a>
<string>foo</string>
<string>bar</string>
</a>
<b>
<number>123</number>
<number>456</number>
</b>
</object>
<object>
<a>
<X>foo</X>
<X>bar</X>
</a>
<b>
<Y>123</Y>
<Y>456</Y>
</b>
</object>
class MyBean {
@Xml(childName="child")
public int[] a;
}
{
a: [123,456]
}
<object>
<a>
<number>123</number>
<number>456</number>
</a>
</object>
<object>
<a>
<child>123</child>
<child>456</child>
</a>
</object>