2016-03-01 24 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

相关问题