【发布时间】:2014-07-10 16:56:35
【问题描述】:
我有一个这样的 XML:
<PROGRAM>
<date>10/07/2014</date>
<name>Name</name>
<LOTS>
<LOT>
<ID>1</ID>
<type>A</type>
</LOT>
<LOT>
<ID>2</ID>
<type>B</type>
</LOT>
</PROGRAM>
我想从转换 (XSLT) 结果中得到这个:
2014 年 10 月 7 日,姓名,1,A
2014 年 10 月 7 日,姓名,2,B
这是我的 xslt:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="text"/>
<xsl:variable name='newline'>
<xsl:text></xsl:text>
</xsl:variable>
<xsl:template match="/">
<xsl:for-each select="//LOT">
<xsl:for-each select="//PROGRAM">
<xsl:value-of select="concat(date,',',name)"/>
</xsl:for-each>
<xsl:value-of select="concat(',',ID,',',type,$newline)"/>
</xsl:for-each>
</xsl:template>
有谁知道 XSLT 可以实现这个目标吗?
谢谢!
【问题讨论】:
标签: xml xslt csv parent-child