Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Syndicate_Admin
Administrator
Administrator

XML anidado

Hola a todos,

Tengo un conjunto de datos que contiene 3 columnas XML. Según el siguiente conjunto de datos.

XML 1XML 2XML 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;? versión xml=&quot;1.0&quot; codificación=&quot;utf-8&quot;? &gt;&lt; RepeaterData&gt;&lt; Versión&gt;&lt;/Versión&gt;&lt;Artículos&gt;...< RepeaterData>< Versión /> MARC111 RYAN122 JUAN4< RepeaterData>< Versión />< NonProductiveTime type=" System.String"> Tiempo de viaje (bienestar a los frentes de trabajo)< NonProductiveTimeMinutes type=" System.Double">20

La columna XML 1 se expande perfectamente cuando se usa la función de análisis XML dentro de Power Query, pero las columnas XML 2 y 3 reciben mensajes de error.

He intentado reemplazar el < con < en las columnas 2 y 3 para que se vea similar a la columna 1, pero aún así no hay suerte.

¿Alguna idea sobre dónde podría estar yendo mal?

Muchas gracias,

Elliot

1 ACCEPTED SOLUTION

@Serdet Pude confirmar para la columna XML 3 que si realiza los siguientes reemplazos, se analiza como XML:

< eso es <

> a >

" a "

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","&lt;","<",Replacer.ReplaceText,{"Column1"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","&gt;",">",Replacer.ReplaceText,{"Column1"}),
    #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","&quot;","""",Replacer.ReplaceText,{"Column1"}),
    #"Parsed XML" = Table.TransformColumns(#"Replaced Value2",{},Xml.Tables)
in
    #"Parsed XML"

View solution in original post

5 REPLIES 5
Syndicate_Admin
Administrator
Administrator

@Serdet ¿También ha intentado reemplazar el > con > también?

Hola Greg,

Gracias por su rápida respuesta. Acabo de probar esto y todavía experimento un error en las columnas 2 y 3.

@Serdet Pude confirmar para la columna XML 3 que si realiza los siguientes reemplazos, se analiza como XML:

< eso es <

> a >

" a "

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","&lt;","<",Replacer.ReplaceText,{"Column1"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","&gt;",">",Replacer.ReplaceText,{"Column1"}),
    #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","&quot;","""",Replacer.ReplaceText,{"Column1"}),
    #"Parsed XML" = Table.TransformColumns(#"Replaced Value2",{},Xml.Tables)
in
    #"Parsed XML"

Eso funcionó un placer, gracias.

¡También se suscribió al canal YT!

@Serdet Es casi seguro que es un problema de codificación. Es como si las columnas XML 2 y 3 estuvieran codificadas en HTML o algo así y eso simplemente no va a funcionar el analizador XML, así que cosas como &quote; tendría que ser cambiado a " y tal. Simplemente no es XML válido, es XML codificado en HTML o algo extraño como eso. Déjame ver si puedo encontrar algo que te permita convertir toda la codificación HTML a la normalidad.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors