0
我試圖解析來自文件的SOAP響應。 這是out.xml使用JDOM解析來自文件的SOAP響應
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<response xmlns="http://tempuri.org/">
<result>
<config>...</config>
<config>...</config>
<config>...</config>
</result>
</response>
</soap:Body>
</soap:Envelope>
這是代碼JDOM:
SAXBuilder builder = new SAXBuilder();
try {
Document document = builder.build(new File("out.xml"));
Element root = document.getRootElement();
Namespace ns = Namespace.getNamespace("http://tempuri.org/");
List r = root.getChildren("config", ns);
System.out.println(r.size());
}
爲什麼這個輸出0?
謝謝。其實我直接尋找特定元素的簡單方法。但它有幫助。 – miqbal