日期:2014-05-18  浏览次数:20757 次

jdom如何解析soap格式的xml
jdom如何解析下面这段xml
SAXBuilder builder = new SAXBuilder(false);
Document doc = null;
try {
  doc = builder.build(new StringReader("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><ns2:QueryResults xmlns:ns2=\"urn:epcglobal:epcis-query:xsd:1\" xmlns:ns3=\"http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader\" xmlns:ns4=\"urn:epcglobal:epcis:xsd:1\" xmlns:ns5=\"urn:epcglobal:epcis-masterdata:xsd:1\"><queryName>SimpleEventQuery</queryName></ns2:QueryResults></soap:Body></soap:Envelope>"));
Namespace senv = Namespace.getNamespace("soap","http://schemas.xmlsoap.org/soap/envelope/");
org.jdom.Element root = doc.getRootElement();
org.jdom.Element body = root.getChild("Body",senv); 
//怎么取queryName和下面的nealnet:VesselName 
}catch (Exception e) {
// TODO: handle exception
}
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
- <soap:Body>
- <ns2:QueryResults xmlns:ns2="urn:epcglobal:epcis-query:xsd:1" xmlns:ns3="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader" xmlns:ns4="urn:epcglobal:epcis:xsd:1" xmlns:ns5="urn:epcglobal:epcis-masterdata:xsd:1">
  <queryName>SimpleEventQuery</queryName> 
- <resultsBody>
- <EventList>
- <ObjectEvent>
  <eventTime>2011-09-22T15:47:00.000+09:00</eventTime> 
  <recordTime>2011-09-22T13:24:05.012+09:00</recordTime> 
  <eventTimeZoneOffset>+09:00</eventTimeZoneOffset> 
- <epcList>
  <epc>urn:un:NEALNET:data:standard:UNCEFACT:CallSign:C6WB6</epc> 
  </epcList>
  <action>DELETE</action> 
  <bizStep>urn:un:unece:uncefact:codelist:standard:UNECE:StatusCode:24</bizStep> 
- <bizLocation>
  <id>urn:un:NEALNET:codelist:standard:UNECEFACT:LoCode:JPTYOAL00C</id> 
  </bizLocation>
  <nealnet:VesselName xmlns:nealnet="http://www.nealnet.org/tracking/extensions/">TRINITY</nealnet:VesselName> 
  <nealnet:VoyageNumber xmlns:nealnet="http://www.nealnet.org/tracking/extensions/">1124S</nealnet:VoyageNumber> 
  <nealnet:ShippingCompanyCode xmlns:nealnet="http://www.nealnet.org/tracking/extensions/">SITC</nealnet:ShippingCompanyCode> 
  <nealnet:CyOpenDateTime xmlns:nealnet="http://www.nealnet.org/tracking/extensions/">2011/09/17</nealnet:CyOpenDateTime>