2017-05-24 27 views
0

我有下面的XML文件:導入XML信息的Excel當缺少的元素

<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> 

當我導入Excel 2016年,我得到這個: enter image description here

這是偉大的,但我希望能夠在「主頁面1」和「主頁面2」中分別獲得一排。我怎樣才能讓Excel包含這些行?

回答

0

我工作圍繞這通過運行通過XSL的XML是複製有孩子的所有節點:

<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>