我正在处理如何映射重复的 xml 元素的问题,当我将下面的 XML 作为 XML 映射导入到 Excel 中时,我只看到我需要的 4 条记录中的 1 条“
我来自微软支持: 此外,如果 XML 映射的内容包含以下 XML 架构构造之一,则无法导出该内容:
列表的列表一个项目列表包含第二个项目列表。
您有什么办法可以建议生成 xml 吗?
下面是我的数据示例:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<PartnersProfile xmlns:xsi="http://www.w3.org/2001/xmlschema-instance">
<ID>10</ID>
<NAME>Table 10</NAME>
<Record>
<PARTNER_ID>1</PARTNER_ID>
<DESCRIPTION>customer</DESCRIPTION>
<subscription>2004</subscription>
<club_LIST>1</club_LIST>
<club_LIST>4</club_LIST>
<club_LIST>6</club_LIST>
<club_LIST>9</club_LIST>
</Record>
<Record>
<PARTNER_ID>1</PARTNER_ID>
<DESCRIPTION>customer</DESCRIPTION>
<subscription>2004</subscription>
<club_LIST>1</club_LIST>
<club_LIST>4</club_LIST>
<club_LIST>6</club_LIST>
<club_LIST>9</club_LIST>
</Record>
</PartnersProfile>
考虑将 XML 转换为每个
club_LIST
的逐项版本,其中祖先元素具有重复值。您可以通过许多工具和编程语言运行下面的 XSLT 1.0,包括 Perl(来自您的个人资料)或 Excel VBA。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="no" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/PartnersProfile">
<xsl:copy>
<xsl:apply-templates select="descendant::club_LIST"/>
</xsl:copy>
</xsl:template>
<xsl:template match="club_LIST">
<Record>
<xsl:copy-of select="ancestor::PartnersProfile/*[name()!='Record']"/>
<xsl:copy-of select="ancestor::Record/*[name()!='club_LIST']"/>
<club_LIST><xsl:apply-templates select="node()"/></club_LIST>
</Record>
</xsl:template>
</xsl:stylesheet>
我遇到了与您相同的问题,并找到了解决方法。
所以基本上在 XML 映射中定义
<club_LIST>bla bla bla</club_LIST>
<club_LIST1>bla bla bla</club_LIST1>
<club_LIST2>bla bla bla</club_LIST2>
这样,当您将地图导入 Excel 时,您将能够将其映射到 3 列,导出后您可以在 notepad++ 中打开导出的文件,它具有强大的“查找和替换”功能(快捷键 ctrl/cmd + f)和您只需立即更改标签
<club_LIST1> </club_LIST1> <club_LIST2> </club_LIST2>
到无数的。