需要帮助使用Power Query将XML导入Excel

时间:2017-04-21 14:57:41

标签: xml excel powerquery google-shopping

提前感谢您提供的任何帮助。我希望在Power Query中找到正确的设置,以导入一些Google Shopping格式的XML。您可以在此处查看XML代码的示例:

<?xml version="1.0"?>
<rss xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0" version="2.0">
    <channel>
            <title>Site anme</title>
            <link><![CDATA[http://www.example.com/]]></link>
            <description>Yada</description>
            <language>EN</language>
            <category>Fashion</category>
            <image><url><![CDATA[http://cdn1.linl.com]]></url></image>
            <currency>GBP</currency>
<item>
                    <title><![CDATA[Some product name]]></title>
                    <link><![CDATA[http://www.somelinke.com]]></link>
                    <g:image_link><![CDATA[http://cdn1.some.image.com]]></g:image_link>
                    <g:age_group>adult</g:age_group>
                    <g:item_group_id><![CDATA[10033]]></g:item_group_id>
                    <g:id><![CDATA[10033]]></g:id>
                    <g:gtin><![CDATA[0207140132]]></g:gtin>
                    <g:size><![CDATA[200]]></g:size>
                    <g:title><![CDATA[Title here]]></g:title>
                    <g:availability>in stock</g:availability>
                    <g:price>20.00 GBP</g:price>
                    <g:description><![CDATA[blah blah blah]]</g:description>
                    <g:mpn><![CDATA[61A0010000]]></g:mpn>
                    <g:brand><![CDATA[Brand]]></g:brand>
                    <g:condition><![CDATA[new]]></g:condition>
                    <g:product_type><![CDATA[Health & Beauty > Personal Care]]></g:product_type>
                    <g:colour><![CDATA[ ]]></g:colour>
                    <g:shipping>
                            <g:price>0.00</g:price>
                    </g:shipping>
                    <g:gender>unisex</g:gender>
                    <g:google_product_category><![CDATA[Health & Beauty]]></g:google_product_category>
                    <g:identifier_exists><![CDATA[TRUE]]></g:identifier_exists>
            </item>
<item>
                    <title><![CDATA[Some product name]]></title>
                    <link><![CDATA[http://www.somelinke.com]]></link>
                    <g:image_link><![CDATA[http://cdn1.some.image.com]]></g:image_link>
                    <g:age_group>adult</g:age_group>
                    <g:item_group_id><![CDATA[10033]]></g:item_group_id>
                    <g:id><![CDATA[10033]]></g:id>
                    <g:gtin><![CDATA[0207140132]]></g:gtin>
                    <g:size><![CDATA[200]]></g:size>
                    <g:title><![CDATA[Title here]]></g:title>
                    <g:availability>in stock</g:availability>
                    <g:price>20.00 GBP</g:price>
                    <g:description><![CDATA[blah blah blah]]></g:description>
                    <g:mpn><![CDATA[61A0010000]]></g:mpn>
                    <g:brand><![CDATA[Brand]]></g:brand>
                    <g:condition><![CDATA[new]]></g:condition>
                    <g:product_type><![CDATA[Health & Beauty > Personal Care]]></g:product_type>
                    <g:colour><![CDATA[ ]]></g:colour>
                    <g:shipping>
                            <g:price>0.00</g:price>
                    </g:shipping>
                    <g:gender>unisex</g:gender>
                    <g:google_product_category><![CDATA[Health & Beauty]]></g:google_product_category>
                    <g:identifier_exists><![CDATA[TRUE]]></g:identifier_exists>
            </item>
<item>
                    <title><![CDATA[Some product name]]></title>
                    <link><![CDATA[http://www.somelinke.com]]></link>
                    <g:image_link><![CDATA[http://cdn1.some.image.com]]></g:image_link>
                    <g:age_group>adult</g:age_group>
                    <g:item_group_id><![CDATA[10033]]></g:item_group_id>
                    <g:id><![CDATA[10033]]></g:id>
                    <g:gtin><![CDATA[0207140132]]></g:gtin>
                    <g:size><![CDATA[200]]></g:size>
                    <g:title><![CDATA[Title here]]></g:title>
                    <g:availability>in stock</g:availability>
                    <g:price>20.00 GBP</g:price>
                    <g:description><![CDATA[blah blah blah]]></g:description>
                    <g:mpn><![CDATA[61A0010000]]></g:mpn>
                    <g:brand><![CDATA[Brand]]></g:brand>
                    <g:condition><![CDATA[new]]></g:condition>
                    <g:product_type><![CDATA[Health & Beauty > Personal Care]]></g:product_type>
                    <g:colour><![CDATA[ ]]></g:colour>
                    <g:shipping>
                            <g:price>0.00</g:price>
                    </g:shipping>
                    <g:gender>unisex</g:gender>
                    <g:google_product_category><![CDATA[Health & Beauty]]></g:google_product_category>
                    <g:identifier_exists><![CDATA[TRUE]]></g:identifier_exists>
            </item>
<item>
                    <title><![CDATA[Some product name]]></title>
                    <link><![CDATA[http://www.somelinke.com]]></link>
                    <g:image_link><![CDATA[http://cdn1.some.image.com]]></g:image_link>
                    <g:age_group>adult</g:age_group>
                    <g:item_group_id><![CDATA[10033]]></g:item_group_id>
                    <g:id><![CDATA[10033]]></g:id>
                    <g:gtin><![CDATA[0207140132]]></g:gtin>
                    <g:size><![CDATA[200]]></g:size>
                    <g:title><![CDATA[Title here]]></g:title>
                    <g:availability>in stock</g:availability>
                    <g:price>20.00 GBP</g:price>
                    <g:description><![CDATA[blah blah blah]]></g:description>
                    <g:mpn><![CDATA[61A0010000]]></g:mpn>
                    <g:brand><![CDATA[Brand]]></g:brand>
                    <g:condition><![CDATA[new]]></g:condition>
                    <g:product_type><![CDATA[Health & Beauty > Personal Care]]></g:product_type>
                    <g:colour><![CDATA[ ]]></g:colour>
                    <g:shipping>
                            <g:price>0.00</g:price>
                    </g:shipping>
                    <g:gender>unisex</g:gender>
                    <g:google_product_category><![CDATA[Health & Beauty]]></g:google_product_category>
                    <g:identifier_exists><![CDATA[TRUE]]></g:identifier_exists>
            </item>
</channel>
</rss>

尽我所能,我找不到合适的方法来导入它。 Power Query由开头部分固定。如果我完全删除它,那么Power Query将忽略任何一个

1 个答案:

答案 0 :(得分:2)

我尝试了你的例子,我在第23行关闭标签后成功导入了。
class myCounter(): def __init__(self): self.lower = 0 self.upper = 0 def count(self, s): if not s: return (self.upper, self.lower) firstCharacter = s[0] if firstCharacter.islower(): self.lower += 1 elif firstCharacter.isupper(): self.upper += 1 else: pass #do nothing ! return self.count(s[1:]) c = myCounter() print(c.count("Town Hall University")) >>> (3, 15) 在此处缺少&gt;
[CDATA [blah blah blah]] &gt; &lt;

<g:description><![CDATA[blah blah blah]]></g:description>

嵌入式表格看起来也不错,也可以打开。