输入xml,我有包含以下格式的xml,我需要在输出中显示为name sae,dadd的详细信息
<?xml version="1.0" encoding="UTF-8"?>
<Employeedetails>
<Employee>
<Name>sae</Name>
</Employee>
<Employee>
<Name>Dadd</Name>
</Employee>
</Employeedetails>XSL:
当前输出:
<?xml version="1.0" encoding="UTF-8"?>
<Customer>
<NameDetaisl>sae,Dadd,</NameDetaisl>
</Customer>发布于 2013-06-16 01:19:55
假设您使用的是xslt-1.0 (因为for-each用于连接名称)。您可以使用position()来避免在列表末尾使用分隔符。
尝试更改for-each,如下所示:
<xsl:for-each select="/Employeedetails/Employee">
<xsl:if test="position() != 1" >
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:value-of select="Name"/>
</xsl:for-each>这将生成:
<NameDetaisl>sae, Dadd</NameDetaisl>https://stackoverflow.com/questions/17125566
复制相似问题