0
我有這個XML文件:JAXB解組沒有作品
<?xml version="1.0" encoding="UTF-8"?>
<diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"
xmlns="http://tempuri.org/" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<DocumentElement xmlns="">
<Result diffgr:id="Result1" msdata:rowOrder="0">
<CITY>York</CITY>
</Result>
</DocumentElement>
</diffgr:diffgram>
我有這樣的Java代碼:
在控制檯輸出我看到null
什麼我錯了嗎?
P.S
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "record")
@XmlAccessorType(XmlAccessType.FIELD)
public class CimRecordTest {
/**
* CITY
*/
@XmlElement(name="CITY")
private String city;
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
}
我做根據http://blog.bdoughan.com/2012/08/handle-middle-of-xml-document-with-jaxb.html P.S - 我看不出差別
附:
Java版本 「1.7.0_45」
爲我工作和打印'約克'。你確定這就是你得到的? –
在我家的電腦 - 也是。但在工作中不起作用 – gstackoverflow
什麼是Java版本都運行? –