Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
导入XML信息Excel时缺少元素_Xml_Excel - Fatal编程技术网

导入XML信息Excel时缺少元素

导入XML信息Excel时缺少元素,xml,excel,Xml,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> &l

我得到了以下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>

当我导入Excel 2016时,我得到以下信息:


这太棒了,除了我希望“主页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>