[英]Missing elements when importing XML info Excel
我有以下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>
很好,除了我希望分別為“主頁1”和“主頁2”各排一行。 如何使Excel包含這些行?
我通過一個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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.