MetricSign
EN|NLRequest Access
Medium severitydata quality

Power BI Refresh Error:
DF-Xml-MalformedFile

What does this error mean?

The XML file is not well-formed and cannot be parsed — unclosed tags, illegal characters, encoding errors, or a missing root element prevent ADF from reading it.

Common causes

  • 1The XML file was truncated mid-write — the producing system crashed or timed out before writing the closing tags
  • 2The file contains special characters (e.g., unescaped ampersands & or angle brackets < > in text content) that are illegal in XML without entity encoding
  • 3The file encoding declared in the XML declaration (<?xml version='1.0' encoding='UTF-8'?>) does not match the actual file encoding
  • 4The file is not XML — it may be HTML, JSON, CSV, or a binary file that was written to the wrong path
  • 5BOM (Byte Order Mark) characters at the start of the file conflict with the XML declaration, corrupting the parser

How to fix it

  1. 1Download the specific XML file that caused the error (the error message includes the file path or name).
  2. 2Open it in a text editor or XML validator (xmlvalidation.com or VS Code XML extension) to identify the exact parsing error and line number.
  3. 3If the file is truncated: investigate why the producing system is writing incomplete files — check timeouts, disk space, and error handling in the upstream system.
  4. 4If the file contains unescaped special characters: fix the upstream system to properly encode them (& → &amp;, < → &lt;, > → &gt;) or pre-process the files with a Copy Activity to a raw landing zone before parsing.
  5. 5If the encoding is wrong: open the file in a hex editor or use 'file' command to determine the actual encoding, then either re-save with the correct encoding or update the XML declaration to match.
  6. 6If the problem is systematic (the source always produces malformed files occasionally), set up error handling in the pipeline to skip or quarantine problematic files rather than failing the entire run.

Frequently asked questions

How do I find which specific XML file caused the malformed file error?

In ADF Monitor, click the failed activity → View details → scroll to the error message. The path appears in the 'Source' or 'File' field. Also check the activity's input/output JSON for the file being processed.

Can the data flow be configured to skip malformed files instead of failing?

Mapping Data Flows have no built-in skip for malformed XML. Standard pattern: use a Copy Activity with fault tolerance to land files to a raw container (it flags bad files), then parse only from the clean landing zone.

What is the difference between a malformed XML file and an invalid XML file?

A malformed XML file violates syntax rules and cannot be parsed. An invalid XML file is syntactically correct but doesn't conform to its schema. MalformedFile is always syntax; schema violations produce InvalidSchema or InvalidElement.

Will downstream Power BI datasets be affected?

Yes — the pipeline fails and the downstream table receives no new data.

Official documentation: https://learn.microsoft.com/en-us/azure/data-factory/data-flow-troubleshoot-guide

Other data quality errors