[英]How to map repeating xml elements in Excel
我正在處理一個關於如何 map 重復 xml 元素的問題,當我將下面的 XML 導入為 excel 中的 XML map 時,我只看到 1 個用於我需要的 4 條記錄“<clist>”<在 output XML 中生成 4 個條目。知道如何在 Excel 中解決這個問題嗎?
我來自 Microsoft 支持:此外,如果內容包含以下 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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.