我有这个SOAP响应:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ConversionRateResponse xmlns="http://www.webserviceX.NET/">
<ConversionRateResult>0.1492</ConversionRateResult>
</ConversionRateResponse>
</soap:Body>
我希望获得价值:
0.1492
如何使用xpath说明这一点?
我的SoapUI响应为'raw'是:
HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/7.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 31 Oct 2014 19:43:54 GMT
Content-Length: 316
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><ConversionRateResponse xmlns="http://www.webserviceX.NET/"><ConversionRateResult>0.1482</ConversionRateResult></ConversionRateResponse></soap:Body></soap:Envelope>
答案 0 :(得分:0)
在纯XPath中,简单地说:
//ConversionRateResult/text()
但是由于XPath通常嵌入到Java或XSLT等高级语言中,您可能也需要(XSLT示例):
<xsl:template match="ConversionRateResult">
<xsl:value-of select="."/>
</xsl:template>