2011-08-12 15 views
0

XPathを使用して、以下のXML文字列にsessionUIDとeNewSTok XML要素を取得しようとしていますが、XPath式を特定できません。 NodeListは空です。レスポンスXMLを見ると、XPathのネームスペースを宣言する必要はないと思います。助言がありますか?XPath固有の要素の検索

応答XML:

<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:Header> 
     <wsu:Timestamp xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility"> 
     <wsu:Created>2011-08-12T03:07:19Z</wsu:Created> 
     <wsu:Expires>2011-08-12T03:12:19Z</wsu:Expires> 
     </wsu:Timestamp> 
    </soap:Header> 
    <soap:Body> 
     <LoginResponse xmlns="http://c1.net.corbis.com/"> 
     <**sessionUID**>{f7be62e6-0bf5-44a7-bf77-5ab2bf307a23}</sessionUID> 
     <**eNewSTok**>JdKVwENgF7SbdBX2x4R+BTA/WiJatMpCJvFckhNtzbx+WZ8OqmSu+fzD36XL4irDsbp69O8YioZl6iYcwrui6NWo6dBh7YCf18A4c4Ry3nFWLpBkUt35sQmBcON1kD79+1lvdJNZrzKOQIDo3Qs/ogb95aVrp7TAgjIkugti3Q0=</eNewSTok> 
     <securityTokenXML><![CDATA[<SecurityToken><ActualMemberUID Scope="Public" Type="Guid" Value="{b7fde077-c13e-40a7-aae9-f18c5a66f3e1}"/><EffectiveMemberUID Scope="Public" Type="Guid" Value="{b7fde077-c13e-40a7-aae9-f18c5a66f3e1}"/><RoleID Scope="Public" Type="Long" Value="49"/><CountryCode Scope="Public" Type="String" Value="US"/><RegionCode Scope="Public" Type="String" Value="CA"/><LanguageID Scope="Public" Type="Long" Value="100958"/><OnyxSessionID Scope="Public" Type="String" Value=""/></SecurityToken>]]></securityTokenXML> 
     </LoginResponse> 
    </soap:Body> 
</soap:Envelope> 

Javaコード:

String responseXML = StringEscapeUtils.unescapeXml(sb.toString()); 
     InputSource source = new InputSource(new StringReader(responseXML)); 
     XPath xPath = XPathFactory.newInstance().newXPath(); 
     NodeList list = (NodeList)xPath.evaluate("(//sessionUID)|(//eNewSTok)", source, XPathConstants.NODESET); 
     for (int i = 0; i < list.getLength(); i++) 
     { 
      System.out.println(list.item(i).getTextContent()); 
     } 

答えて