Forum Discussion

GrahamR's avatar
GrahamR
Frequent Visitor
10 months ago
Solved

XML import problem

I have an XML file delivered to me where I need to display the Location text field.  I have tried various ways but need some help please.   Minimal example xml (just 1 object) is here and the text ...
  • v-tejrama's avatar
    v-tejrama
    10 months ago

    Hi GrahamR ,

     

    You are correct this is the expected behavior.

    The reason you are seeing only null values is that the plain text “Site A” is not retained when Power BI parses the XML. The Xml.Tables function processes only structured elements and attributes, and in your file, “Site A” appears as loose text before the <Shelf> and <Box> elements. As a result, it is considered mixed content and omitted during import.

    Since this text does not make it into Power Query, it cannot be retrieved by any M or DAX expressions after the XML is loaded.

     

    The best solutions are to either update the XML so that “Site A” is within its own tag or attribute, or to read the file as raw text and extract the relevant section before <Shelf> using text functions prior to converting it to XML.

    In summary, your understanding is correct the data loss occurs during the XML parsing stage, and is not due to any issues with your process.

    Thank you,

    Tejaswi