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.

n8n
Create XML Files from MySQL: With & Without Attributes

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.

$11.99
Last updated September 5, 2026
30-day money-back guarantee
Instant download
Lifetime updates included

New buyers can create an account from the cart to unlock a controlled $10 first-purchase credit on eligible orders of $25+.

Secure checkout powered by Stripe

Support

How to import this workflow into n8n

  1. 1Purchase or download the workflow to get the n8n workflow JSON file.
  2. 2In your n8n instance, open Workflows and choose "Import from File" (or paste the JSON with Ctrl+V on the canvas).
  3. 3Open each node marked with a credential warning and connect your own accounts and API keys.
  4. 4Run the workflow once manually to verify the data flow, then toggle it to Active.

Related AI workflows

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.