2016-03-01 73 views
1

我以前http://www.freeformatter.com/xpath-tester.html來獲得爲什麼我的XPath表達式不匹配?

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
        xmlns:paf="http://paf.mycompany.com/"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <paf:requestpafBean> 
      <!--Optional:--> 
      <arg0> 
       <!--Optional:--> 
       <UserId>?</UserId> 
       <!--Optional:--> 
       <DateNow>?</DateNow> 
      </arg0> 
     </paf:requestpafBean> 
    </soapenv:Body> 
    </soapenv:Envelope> 

UserId值來測試這個XPath表達式:

//paf:UserId[1]/@text 

我爲什麼會不匹配?

+0

@kjhughes謝謝我更新。我也試圖改變我的xpath表達式,沒有運氣 – user310291

回答

4

以下XPath表達式,

//UserId/text() 

將選擇?的要求。

注:

  • UserId是沒有命名空間,所以你不想做paf:UserId
  • 如果有多個UserId,您可以將UserId[1]添加到您的 表達式中。
  • 上有UserId沒有text屬性,所以你不想UserId/@text,但有UserId下方text()節點,所以你想UserId/text()
  • 如果在UserId之下可能存在進一步標記,則可能需要其字符串 值string(//UserId),而不是選擇其子文本節點。
+2

@kjhugues適用於soapui嘲笑。非常感謝你挽救了我的一天工作 – user310291

相關問題