2011-12-16 109 views
0
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
<soap:Body><getSessionId xmlns="http://treecorp.corp:8080/MEENH/service"> 
<multiRef xmlns:apachesoap="http://xml.apache.org/xml-soap" 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
xsi:type="apachesoap:Map"> 
<item> 
    <key xsi:type="soapenc:string">Application</key> 
    <value xsi:type="soapenc:string">MobileDevice</value> 
</item> 
<item> 
    <key xsi:type="soapenc:string">Version</key> 
    <value xsi:type="soapenc:string">1.0</value> 
</item> 
<item> 
    <key xsi:type="soapenc:string">Username</key> 
    <value xsi:type="soapenc:string">ramau</value> 
</item> 
<item> 
    <key xsi:type="soapenc:string">token</key> 
    <value xsi:type="soapenc:string"></value> 
</item> 
<item> 
    <key xsi:type="soapenc:string">sessionID</key> 
    <value xsi:type="soapenc:string">SESSIONID</value> 
</item> 
<item> 
    <key xsi:type="soapenc:string">OSInformation</key> 
    <value xsi:type="soapenc:string">windowsXP</value> 
</item> 
</multiRef> 
</getSessionId> 
</soap:Body> 
</soap:Envelope> 

这是我的XML。使用java解析XML

我想用Java解析这个XML,并根据关键值检索一个值。您可以在XML中看到很多关键值对。

例如,如果我想回收应用程序的值,我应该得到的值为MobileDevice。 像这样友善的人帮我排序这个问题。

在此先感谢。

回答

0

既然它是一个soap响应,为什么不写一个漂亮简单的Web服务客户端来检索响应并自动将它转换为对象。

有一个这样的例子here