我正在尝试从文件中解析 SOAP 响应。这是 out.xml
<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?