我有以下XML文件:
<toc label="My information" href="index.html">
<topic label="Main page 1" href="topics/one.html">
<topic label="1a" href="topics/1a.html"/>
<topic label="1b" href="topics/1b.html"/>
</topic>
<topic label="Main page 2" href="topics/two.html">
<topic label="2a" href="topics/2a.html"/>
<topic label="2b" href="topics/2b.html"/>
</topic>
</toc>
这很棒,除了我希望每个人都能获得一行#34;主页1&#34;和&#34;主页2&#34;。如何让Excel包含这些行?
答案 0 :(得分:0)
我通过XSL运行XML来解决这个问题,该XSL复制了所有有孩子的节点:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="toc">
<topic label="{@label}" href="{@topic}">
<xsl:apply-templates/>
</topic>
</xsl:template>
<xsl:template match="topic">
<topic label="{@label}" href="{@href}">
<!-- if topic has children, insert another copy here -->
<xsl:if test="topic">
<topic label="{@label}" href="{@href}"/>
</xsl:if>
<xsl:apply-templates/>
</topic>
</xsl:template>
</xsl:stylesheet>