Forum Discussion
Nested XML
Hi everyone,
I have a dataset which contains 3 XML columns. As per the below dataset.
| XML 1 | XML 2 | XML 3 |
| <?xml version="1.0" encoding="utf-8"?><RepeaterData><Version>1.0</Version><Items><Item><_68314b7831992f9f8d5e7a725ac659c1 type="System.String">test</_68314b7831992f9f8d5e7a725ac659c1><_531ea9e5be0e9226154a6a7e1dc1a130 type="System.String">Safety Valves</_531ea9e5be0e9226154a6a7e1dc1a130><_c9900ef32f210afc9c82eb1d2c3c1f29 type="System.String">1234</_c9900ef32f210afc9c82eb1d2c3c1f29><_a48b2fb7f47ecd63ec47072da6fb32b9 type="System.String">1234</_a48b2fb7f47ecd63ec47072da6fb32b9><_23e7af02b8986bb9f7c72734eefe74f8 type="System.String">On tools</_23e7af02b8986bb9f7c72734eefe74f8><_648088b77175e86d99d0f0dadbb2a43c type="System.String">IST Maintenance</_648088b77175e86d99d0f0dadbb2a43c><_2c69e069b76b5469b7a37b892d6efa60 type="System.String">me</_2c69e069b76b5469b7a37b892d6efa60><_a056422922319cf1758dde9c07206d49 type="System.String">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;RepeaterData&gt;&lt;Version&gt;&lt;/Version&gt;&lt;Items&gt;... | <?xml version="1.0" encoding="utf-8"?><RepeaterData><Version /><Items><Item><control_EmployeeName type="System.String">MARC</control_EmployeeName><control_NHours type="System.Int32">1</control_NHours><control_PHours type="System.Int32">1</control_PHours><control_DHours type="System.Int32">1</control_DHours></Item><Item><control_EmployeeName type="System.String">RYAN</control_EmployeeName><control_NHours type="System.Int32">12</control_NHours><control_PHours type="System.String"></control_PHours><control_DHours type="System.Int32">2</control_DHours></Item><Item><control_EmployeeName type="System.String">JOHN</control_EmployeeName><control_NHours type="System.Int32">4</control_NHours><control_PHours type="System... | <?xml version="1.0" encoding="utf-8"?><RepeaterData><Version /><Items><Item><NonProductiveTime type="System.String">Travel time (welfare to work-fronts)</NonProductiveTime><NonProductiveTimeMinutes type="System.Double">20</NonProductiveTimeMinutes></Item></Items></RepeaterData> |
XML column 1 expands perfect when using the parse XML function within Power Query but XML columns 2 & 3 get error messages.
I have tried replacing the < with < in columns 2 & 3 in order to make it look similar to column 1 but still no luck.
Any ideas as to where I might be going wrong?
Many thanks,
Elliot
Anonymous I was able to confirm for XML column 3 that if you do the following replacements that it parses as XML:
< to <
> to >
" to "
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZExC8IwEIX/Suikg6Z2EKGISxcHRVRc1CHqVYJpTpNL1X9vpVICqeKWe5d738tlu412Lo6ToaJ08igUK8FYiXpcqzeHlA76sVcx0Ec8SX32rzjKeyOvntTnM6WN+xKuIAhMJkiE3U2NZTxsTQkK2y6H6hz1wuDJHUmWsJYFMHpewY+6etpqsr8iU73B0xuvtRElKEbv4c4dVC5M5YLsjubSyw1qst2GxwPgH5lmUjsC+y1ahu6goC1aEv8Af1xDPm9fFf+yWN76U9F+/wI=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}), #"Replaced Value" = Table.ReplaceValue(#"Changed Type","<","<",Replacer.ReplaceText,{"Column1"}), #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",">",">",Replacer.ReplaceText,{"Column1"}), #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1",""","""",Replacer.ReplaceText,{"Column1"}), #"Parsed XML" = Table.TransformColumns(#"Replaced Value2",{},Xml.Tables) in #"Parsed XML"
5 Replies
- Greg_Deckler
Community Champion
Anonymous Have you also tried replacing the > with > as well?
- AnonymousNot applicable
Hi Greg,
Thanks for your quick response. I just tried this and still experience an error on columns 2 & 3.
- Greg_Deckler
Community Champion
Anonymous It's almost certainly an encoding issue. It's like XML columns 2 and 3 were HTML encoded or something and that's just not going to work the the XML parser so things like "e; would need to be changed to " and such. It's just not valid XML it is HTML encoded XML or something weird like that. Let me see if I can find something that will allow you to convert all of the HTML encoding back to normal.