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
- 1Download the specific XML file that caused the error (the error message includes the file path or name).
- 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.
- 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.
- 4If the file contains unescaped special characters: fix the upstream system to properly encode them (& → &, < → <, > → >) or pre-process the files with a Copy Activity to a raw landing zone before parsing.
- 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.
- 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
Official documentation: https://learn.microsoft.com/en-us/azure/data-factory/data-flow-troubleshoot-guide