Power Query Table to XML
✓ Published0🌍 Public
HHugoberry
Last edited Apr 6, 2017
Created on Apr 5, 2017
This example demonstrates a Power Query M function that converts a table into a nested XML structure, using a recursive custom function named `tab2xmlREC` to handle tables, records, and scalar values. The initial sample table, created with `#table(null,{{1,2},{3,4}})` and typed via `Value.ReplaceType`, is transformed into a string of XML elements. The implementation relies on `Table.ToRecords`, `List.Accumulate`, and `Record.FieldNames` to iterate over rows and fields, while `Text.Format` builds the XML tags. The output shows a flat representation for simple values, and the recursive call handles nested tables or records, producing a hierarchical XML string.
AI-generated description