Create XML Files from MySQL: With & Without Attributes
This workflow fetches random products from a MySQL database and exports them to two XML files—one with a simple structure and one with XML attributes—demonstrating versatile data export techniques.
This n8n workflow automates the extraction of data from a MySQL database and its conversion into XML format in two variations: a basic structure without attributes and an advanced one using attributes defined via dollar-sign prefixed JSON keys. It starts with a manual trigger, queries 16 random product records from a 'products' table using a simple SQL statement with RAND() ordering, then branches into two parallel paths. In the upper path, a Set node defines the XML structure by mapping fields like productCode, productName, productLine, productScale, and MSRP. An Item Lists node aggregates items into an array, enabling the XML node to generate a clean, nested XML file which is then saved locally.
The lower path mirrors this process but incorporates XML attributes by prefixing keys with '$' in the Set node (e.g., $attributeName), allowing for richer metadata in the output XML. Both files are persisted to the local filesystem, providing immediate downloadable results. This dual approach highlights n8n's flexibility in handling XML generation without custom code.
Benefits include time savings in data export tasks, eliminating manual scripting for XML formatting, and ensuring consistency across outputs. It's ideal for legacy system integrations, report generation, or preparing data for applications that require specific XML schemas. Use cases span e-commerce product catalogs, inventory reporting, data migration to XML-based systems, or testing XML parsers, making it valuable for developers and analysts needing quick, repeatable exports from relational databases.
New buyers can create an account from the cart to unlock a controlled $10 first-purchase credit on eligible orders of $25+.
Related bundle
Content Repurposing Engine
8 hand-picked workflows for $29.00.
That is $3.63 each, vs $11.99 for this one alone.
View bundleSecure checkout powered by Stripe
Support
How to import this workflow into n8n
- 1Purchase or download the workflow to get the n8n workflow JSON file.
- 2In your n8n instance, open Workflows and choose "Import from File" (or paste the JSON with Ctrl+V on the canvas).
- 3Open each node marked with a credential warning and connect your own accounts and API keys.
- 4Run the workflow once manually to verify the data flow, then toggle it to Active.
Related AI workflows
- Launch Your First AI-Powered Chatbot with Actionable Tools$9.99
- Automate AI Video Creation and YouTube Upload with Google Sheets$14.99
- Build a WhatsApp Assistant with Memory, Google Suite, Multi-AI, Research, and Imaging$24.99
- Automate Blog Post Creation and Publishing with GPT, Leonardo AI, and WordPress$14.99
- Automate SEO Keyword Generation with ChatGPT from Google Sheets$3.99
- Email Agent$500.99
More from Maxim Luong
Need this deployed? We'll set it up for you.
Our automation experts deploy this workflow in your stack, connect your accounts, and verify it works — or build a custom solution from scratch.