Forum Discussion
Blue_BIGuy
3 years agoFrequent Visitor
Column in xml format convert it to readable format.
Hello All, I am extracting the data from SQL DB, one of the column of the table contents data in below (As it) format. Kindly guide, how can I achieve (To Be) format. As is To Be ...
- 3 years ago
Hi Blue_BIGuy ,
Here is a handy M Function for stripping all the HTML tags:
let func = (HTML) => let Check = if Value.Is(Value.FromText(HTML), type text) then HTML else "", Source = Text.From(Check), SplitAny = Text.SplitAny(Source,"<>"), ListAlternate = List.Alternate(SplitAny,1,1,1), ListSelect = List.Select(ListAlternate, each _<>""), TextCombine = Text.Combine(ListSelect, "") in TextCombine, documentation = [ Documentation.Name = " Text.RemoveHtmlTags" , Documentation.Description = "Remove Html Tags" , Documentation.LongDescription = " Removes all Html tags from a text" , Documentation.Category = " Text.Modification" , Documentation.Source = " Inspired by a solution from Bill Szysz" , Documentation.Author = " Imke Feldmann: www.TheBIccountant.com & Mike Carlo: PowerBI.Tips" , Documentation.Examples = {[ Description = "Function that enables one to pass in a column that has HTML tags." , Code = "<div>my bit of text</div>" , Result = "my bit of text " ]}] in Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation))Please try to create a new blank query and paste the above code into the advanced editor:
Then you can use this function directly:
Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-jianboli-msft
3 years agoCommunity Support
Hi Blue_BIGuy ,
Here is a handy M Function for stripping all the HTML tags:
let func = (HTML) =>
let
Check = if Value.Is(Value.FromText(HTML), type text) then HTML else "",
Source = Text.From(Check),
SplitAny = Text.SplitAny(Source,"<>"),
ListAlternate = List.Alternate(SplitAny,1,1,1),
ListSelect = List.Select(ListAlternate, each _<>""),
TextCombine = Text.Combine(ListSelect, "")
in
TextCombine,
documentation = [
Documentation.Name = " Text.RemoveHtmlTags"
, Documentation.Description = "Remove Html Tags"
, Documentation.LongDescription = " Removes all Html tags from a text"
, Documentation.Category = " Text.Modification"
, Documentation.Source = " Inspired by a solution from Bill Szysz"
, Documentation.Author = " Imke Feldmann: www.TheBIccountant.com & Mike Carlo: PowerBI.Tips"
, Documentation.Examples = {[
Description = "Function that enables one to pass in a column that has HTML tags."
, Code = "<div>my bit of text</div>"
, Result = "my bit of text "
]}]
in
Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation))
Please try to create a new blank query and paste the above code into the advanced editor:
Then you can use this function directly:
Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Blue_BIGuy3 years agoFrequent Visitor
Thanks v-jianboli-msft