我有以下soap响应,想要提取产品列表:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<listProductsResponse xmlns="http://warehouse.acme.com/ws">
<listProductsResult>
<listProductsResult>
<productName>hammer</productName>
<productId>54112</productId>
</listProductsResult>
<listProductsResult>
<productName>drill</productName>
<productId>54113</productId>
</listProductsResult>
<listProductsResult>
<productName>circular saw</productName>
<productId>54114</productId>
</listProductsResult>
<listProductsResult>
<productName>jigsaw</productName>
<productId>54115</productId>
</listProductsResult>
</listProductsResult>
</listProductsResponse>
</soapenv:Body>
</soapenv:Envelope>
以下XPath返回“No Match”。我想知道为什么?
/soapenv:Envelope/soapenv:Body/ns:listProductsResponse
以下是有效的,但在我看来是一种肮脏的方法,因为为listProductsResponse指定了名称空间:
/soapenv:Envelope/soapenv:Body/*[local-name()="listProductsResponse"]