【发布时间】:2014-06-05 06:29:09
【问题描述】:
我正在尝试使用 moxy 将 xml 解组为对象。下面是 xml 的示例。
<root>
<name>
<firstname>value</firstname>
</name>
<address>value of address</address>
</root>
下面是我要映射的类。
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.eclipse.persistence.oxm.annotations.XmlPath;
@XmlRootElement(name="root")
@XmlAccessorType(XmlAccessType.FIELD)
public class Response {
@XmlPath("name/firstname/text()")
String name;
Address address;
}
class Address {
String addressline;
}
现在如何获取 XML 中地址标签的值并将其绑定到类地址的地址线变量。
【问题讨论】:
标签: java xml jaxb unmarshalling moxy