67,513
社区成员
发帖
与我相关
我的任务
分享
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:LST_SBRResponse xmlns:ns1="http://www.xxx.com/a/">
<ns1:Result>
<ns1:ResultCode>0</ns1:ResultCode>
<ns1:ResultDesc>Operation succeeded.</ns1:ResultDesc>
<ns1:ResultData>
<ns1:Table1>
<ns1:Item>
<ns1:GRPIDX>65535</ns1:GRPIDX>
<ns1:SCADDRIDX>65535</ns1:SCADDRIDX>
<ns1:CDNOCB>0</ns1:CDNOCB>
<ns1:PBTSBR>
<ns1:PBXID />
<ns1:ISPILOT>0</ns1:ISPILOT>
<ns1:ISSHARESRV>0</ns1:ISSHARESRV>
</ns1:PBTSBR>
<ns1:KVALUE>255</ns1:KVALUE>
<ns1:INPFIDX>65535</ns1:INPFIDX>
</ns1:Item>
</ns1:Table1>
</ns1:ResultData>
</ns1:Result>
</ns1:LST_SBRResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
SAXReader saxReader = new SAXReader();
Document document = saxReader.read(test.class.getResourceAsStream("po.xml"));
DefaultXPath xpath = new DefaultXPath("//ns1:Item");
xpath.setNamespaceURIs(Collections.singletonMap("ns1","http://www.xxx.com/a/"));
List list = xpath.selectNodes(document);
Iterator iterator = list.iterator();
int i = 1;
while (iterator.hasNext()) {
Element node = (Element) iterator.next();
System.out.println(i++ + node.getName());
}
while (iterator.hasNext()) {
Element node = (Element) iterator.next();
System.out.println(i++ + node.getName());
//即是Item下的所有子结点
List<Element> eleList = node.elements();
}
while (iterator.hasNext()) {
Element node = (Element) iterator.next();
System.out.println(i++ + node.getName());
List<Element> eleList = node.elements();//即是Item下的所有子结点
}