2011-12-16 117 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