2016-10-11 72 views
0

我想從以下XML檢索幾個節點的命名空間:的XPath用VBS

<?xml version="1.0" encoding="UTF-8"?> 
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <soap:Body> 
     <CheckPersonResponse xmlns="http://test.net/crs/"> 
     <CheckPersonResult> 
      <xml xmlns="http://test.com/webservices/crs2/"> 
       <requestid>933ca7df-6f25-49d9-8144-692e9f18cf27</requestid> 
       <customernumber>xxx</customernumber> 
       <reference>xx</reference> 
       <product>xxx</product> 
       <input> 
        <customernumber>xx</customernumber> 
        <reference>xx</reference> 
        <name>xx</name> 
        <initials>xx</initials> 
        <prefix>xx</prefix> 
        <gender>xx</gender> 
        <birthdate>xxx</birthdate> 
        <streetname>x</streetname> 
        <housenumber>x</housenumber> 
        <extension>Axx</extension> 
        <postcode>xx</postcode> 
        <city>xx</city> 
        <country /> 
        <phonenumber1 /> 
        <phonenumber2 /> 
        <emailaddress /> 
        <bankaccount /> 
        <referencedate>xxx</referencedate> 
        <typeofclaim>xx</typeofclaim> 
        <claimdate>xxx</claimdate> 
        <claimamount>xx</claimamount> 
       </input> 
       <result> 
        <reference>xxx</reference> 
        <personalscore>0</personalscore> 
        <statisticalscore>0</statisticalscore> 
        <paymentscore>0</paymentscore> 
        <overallscore>0</overallscore> 
        <addressindicator /> 
       </result> 
      </xml> 
     </CheckPersonResult> 
     </CheckPersonResponse> 
    </soap:Body> 
</soap:Envelope> 

,我想檢索標籤<result>我如何可以選擇所有與節點的所有節點XPath並在vbs中使用它們?

在此先感謝!

+1

這已經被問過很多次。搜索。 (更不用說,有MSDN上的官方文檔解釋了這些東西。) – Tomalak

+0

我得到,我需要設置一個xmlns,儘管xpath xml:xml即使它沒有被定義它不會返回錯誤... –

+0

你不顯示你的代碼,你沒有解釋你已經嘗試了什麼,你沒有引用錯誤信息...... *和*有幾百個基本上可以複製和粘貼就緒的代碼示例在這個網站和互聯網上的其他地方的這個問題。真。花20分鐘搜索,你會發現至少有一個,很可能更多。 – Tomalak

回答

0

找到了解決辦法:

xmlhttp.responseXML.setProperty "SelectionNamespaces", "xmlns:s='http://test.nl/webservices/crs2/' xmlns:c='http:/test.net/crs/' xmlns:soap='http://www.w3.org/2003/05/soap-envelope' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'" 

Set NodeList = xmlhttp.responseXML.selectNodes("/soap:Envelope/soap:Body/c:CheckPersonResponse/c:CheckPersonResult/s:xml/s:result/s:*")