“Extract from File” or “XML to JSON” removes filename after conversion — how to preserve it?
Hi everyone ![]()
I’m having an issue in n8n where I process multiple XML reports for an animal shelter.
Each file contains structured data (for example, adoption reports, vet checkups, and feeding logs).
I read these XML files using Read XML File, and then convert them to JSON using Extract from File (or XML to JSON).
The conversion itself works, but the problem is that the original file name (filename) and path fields are lost after the Extract node.
All metadata disappears — only the parsed XML content (Document) remains.
What I already tried
- Enabling “Include Other Input Fields” on all intermediate nodes.
- Setting “Keep Source = JSON” and “Keep Source = Both” in Extract from File.
- Copying the filename manually into
binary.data.fileNameorjson.filename. - Replacing the XML to JSON node with a Code node using
n8n-workflow.XMLParser.
No matter what I do, the filename is always gone after the extraction step.
Example of what happens
Before Extract from File:
{
"path": "/data/animal-shelter/reports/2025/adoption-report.xml",
"filename": "adoption-report.xml",
"binary": {
"data": {
"fileName": "adoption-report.xml",
"data": "<xml>...</xml>"
}
}
}
After Extract from File:
{
"Document": {
"AnimalReport": { "..." : "..." }
}
}
The filename and path fields are completely lost.
Expected output
{
"filename": "adoption-report.xml",
"path": "/data/animal-shelter/reports/2025/adoption-report.xml",
"Document": {
"AnimalReport": { "..." : "..." }
}
}
Workflow example
Read XML File → Extract from File → Code → Spreadsheet File
Workflow JSON (simplified):
Information on my n8n setup
- n8n version: last update
- Database (default: SQLite): postgress
- n8n EXECUTIONS_PROCESS setting (default: own, main): own
- Running n8n via: Docker
- Operating system: Debian 13
Summary
It looks like the Extract from File (and possibly XML to JSON) node doesn’t preserve JSON fields from the input item (such as filename/path).
Is this expected behavior, or could it be a bug?
What’s the proper way to keep the original file metadata when converting XML to JSON?