如何将xpath写入checkAddResult值

如何将xpath写入checkAddResult值,xpath,soapui,Xpath,Soapui,如何编写XPath以获取AddResult文本值 <soap:Envelope 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"> <soap:Body> <A

如何编写XPath以获取AddResult文本值

  <soap:Envelope 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">
     <soap:Body>
       <AddResponse xmlns="http://tempuri.org/">
         <AddResult>128</AddResult>
       </AddResponse>
     </soap:Body>
  </soap:Envelope>

找到Answeer:

我应该创建另一个名称空间,其url与响应xml中的url相同,并在xpath中使用,下面是答案

declare namespace soap='http://www.w3.org/2003/05/soap-envelope';
declare namespace xmlns='http://tempuri.org/';
/soap:Envelope/soap:Body/xmlns:AddResponse/xmlns:AddResult/text()

当您仅使用
//AddResult/text()
时会发生什么情况?@JackFleeting我们将得到一个错误,因为XPath缺少内容。对于读取数据,您可以只使用任何命名空间的通配符:
/*:AddResponse/*:AddResult
declare namespace soap='http://www.w3.org/2003/05/soap-envelope';
declare namespace xmlns='http://tempuri.org/';
/soap:Envelope/soap:Body/xmlns:AddResponse/xmlns:AddResult/text()