如何编写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>
我在下面尝试过但没有得到想要的结果
declare namespace soap='http://www.w3.org/2003/05/soap-envelope';
/soap:Envelope/soap:Body/AddResponse/AddResult/text()
Found Answeer:
我应该使用与响应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()