我从REST API象下面这样的XML响应:
<?xml version="1.0" encoding="UTF-8"?>
<ns2:testpla xmlns:ns2="http:xyz" xmlns:ns7="xyz">
<ns2:category term="Default Category" value="Default Category Value"/>
<ns2:testase ns7:resource="https://www.cyz.com" units="PH"
href="ww.com">XYZ</ns2:testase>
<ns2:testase ns7:resource="https://ww.cyz.com" units="LH"
href="ww.org">AZ</ns2:testase>
<com.abc xmlns="http://lq.net" extensionDisplayName="QWZ-KEY-TP-TEST-ZWE-
TI">
<div xmlns="http://www.w3.org/1999/xhtml">TriggerA ND confirm the
functionality</div>
</com.abc>
</ns2:testpla>
我知道如何让IE“XYZ”使用JAXB的XML元素值和绑定到豆。但我坚持就知道如何获取资源的值(即,“https://www.cyz.com”),单位(“PH”),HREF(“ww.com”),里面的div的xmlns的值,然后映射的值?反对财产。请帮我。
创建单独的两个类的testpla和testase
test PLA.Java
@XmlRootElement(name = "ns2:testpla")
public class Testpla {
private Testase testase;
public Testase getTestase() {
return testase;
}
@XmlElement(name = "ns2:testase")
public void setTestase(Testase testase) {
this.testase = testase;
}
}
test A色.Java
@XmlRootElement(name = "ns2:testase")
public class Testase {
private String resource;
private String units;
public String getResource() {
return resource;
}
@XmlAttribute(name = "ns7:resource")
public void setResource(String resource) {
this.resource = resource;
}
public String getUnits() {
return units;
}
@XmlAttribute(name = "units")
public void setUnits(String units) {
this.units = units;
}
}