【发布时间】:2013-04-06 15:03:16
【问题描述】:
我有这个基本的 SOAP 响应:
<?xml version="1.0" encoding="WINDOWS-1252" standalone="yes"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body xmlns="http://www.xxx.com/dotnet/types/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<a>
<b>
<c>
c-value
</c>
b-value
</b>
a-value
</a>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我只想输出c节点的值:c-value。
我不明白为什么这个 xsl 不起作用:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
>
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:value-of select="//c"/>
</xsl:template>
</xsl:stylesheet>
似乎问题出在<SOAP-ENV:Body xmlns="http://www.xxx.com/dotnet/types/" 的名称空间中
如果我删除它,它会起作用。
我想我应该更改 select="//c" 中的 xpath 或在 xls 中的某处添加所需的命名空间,但我做错了!
【问题讨论】:
-
是的确实...经过数小时的搜索和试验,链接在编写问题时出现了,这就是为什么我将它包含在我的答案中...这是相同的情况,但适用于 SOAP ,很容易被忽略。但我同意,这是重复的
标签: xslt soap xml-namespaces