How to display xml attribute into column?

Viewed 36

i have the following XML structure :

<?xml version='1.0' encoding='UTF-8'?>
<catalog xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' language='FR' country='FR'>
    <produit id='1234'>
        <color><![CDATA[red]]></color>
        <fermete><![CDATA[hard]]></fermete>
        <forme><![CDATA[square]]></forme>
    </produit>
</catalog>

When i load this xml into power query, i can see xml tags (couleur / fermete / forme) as columns, but the attribute data "id='1234' is not get.

This is the power query used :

let
    Source = Xml.Tables(File.Contents("file.xml")),
    #"Type modifié" = Table.TransformColumnTypes(Source,{{"Attribute:language", type text}, {"Attribute:country", type text}}),
    #"produit développé" = Table.ExpandTableColumn(#"Type modifié", "produit", {"color", "fermete", "forme"})
in
    #"produit développé"

Is it possible to get it ?

1 Answers

You need to include the column on the expand

#"produit développé" = Table.ExpandTableColumn(#"Type modifié", "produit", {"color", "fermete", "forme", "Attribute:id"}, {"color", "fermete", "forme", "Attribute:id"})
Related