We have stuck in sth that should be trivial. We have the following XML:
<someRoot>
<aList>
<item atr="value">otherValue</item>
<item atr="someValue">someOtherValue</item>
....
</aList>
</someRoot>
We are unable to get the "otherValue" or "someOtherValue" which is inner text in the item node. No problem with the attribute. I'm not going to post all annotation test we have done to make this simple.
Any way, how should the SomeRoot, AList and Item classes be annotated to make this work? Sample should work with and array and retrieve both attributes and inner text. Thanks in advance to the community.
You can use @XmlValue
for the property mapping to the inner text.
@XmlAccessorType(XmlAccessType.FIELD)
public class Item {
@XmlAttribute
private String atr;
@XmlValue
private String value;
}
For More Information
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.