67,549
社区成员




<?xml version="1.0" encoding="UTF-8"?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Body>
<ZPILOT01_KTSC_MMIF022_N.Response xmlns="urn:sap-com:document:sap:rfc:functions.response">
<ERSDA1>0000-00-00</ERSDA1>
<LAEDA1>0000-00-00</LAEDA1>
<MAKTX/>
<MATKL/>
<MATNR/>
<MEINS/>
<ITAB>
<item>
<MATNR> 0000300280</MATNR>
<MAKTX>燃料气</MAKTX>
<MEINS>M3</MEINS>
<MATKL>07020102</MATKL>
<ERSDA>2016-12-29</ERSDA>
<LAEDA/>
<LVORM/>
<ZMLLX/>
<EKGRP>L78</EKGRP>
</item>
<item>
<MATNR>00000300644</MATNR>
<MAKTX>0号 车用柴油(Ⅴ)</MAKTX>
<MEINS>TO</MEINS>
<MATKL>07030301</MATKL>
<ERSDA>2017-08-29</ERSDA>
<LAEDA>2018-11-15</LAEDA>
<LVORM/>
<ZMLLX/>
<EKGRP/>
</item>
</ITAB>
</ZPILOT01_KTSC_MMIF022_N.Response></soap-env:Body></soap-env:Envelope>
/根据"/"路径获取元素
List<Element> list = root.selectNodes("/companys/company/name");
System.out.println(list.size());
for (Element element : list) {
System.out.println("name元素的值是:"+element.getText());
}
//根据"//"路径获取元素
List<Element> list1 = root.selectNodes("//name");
System.out.println(list1.size());
for (Element element : list1) {
System.out.println("name元素的值是:"+element.getText());
public static void main(String[] args) {
SAXReader reader = new SAXReader();
try {
Document document = reader.read(new File("src/book.xml"));
Element bookStore = document.getRootElement().element("Body").element("ZPILOT01_KTSC_MMIF022_N.Response").element("ITAB");
Iterator it = bookStore.elementIterator();
while (it.hasNext()) {
System.out.println("=====开始遍历=====");
Element book = (Element) it.next();
Iterator itt = book.elementIterator();
while (itt.hasNext()) {
Element bookChild = (Element) itt.next();
System.out.println("节点名:" + bookChild.getName() + " ------节点值:" + bookChild.getStringValue());
}
System.out.println("=====结束遍历=====");
}
} catch (DocumentException e) {
e.printStackTrace();
}
}