对于这种简单的xml,有没有办法使用单个java bean进行映射:
<item lang="en">
<item-url>some url</item-url>
<parent id="id_123"/>
</item>
我试过这样的事情:
@XmlRootElement( name = "item" )
public class Item {
@XmlElement( name = "item-url" )
private String url;
@XmlAttribute( name = "parent/@id" )
// Of course XPath doesn't work here, but it would be great...
private String parentId;
}
换句话说 - 如何在不创建相应 bean 的情况下访问内部元素的属性?