Mock XML Generator

Structured XML test data for legacy systems

Generate well-formed XML documents with a configurable root element, repeated record elements, and fake typed values. Test XML parsers, SOAP integrations, and legacy enterprise systems without hand-writing sample payloads. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

Is the generated XML well-formed?

Yes. Every document starts with an XML declaration, has a single root element, properly nests child elements, and escapes the five XML special characters (& < > " ') in text content, so it parses cleanly in any conformant parser.

Mock XML Generator

Legacy enterprise systems, SOAP services, and older integrations still speak XML, and testing them requires realistic, well-formed sample documents. Hand-writing XML is tedious and error-prone, especially when you need dozens of records. This tool generates a valid XML document with a configurable structure and fake typed values in one click.

How it works

The generator builds a document with an XML declaration (<?xml version="1.0" encoding="UTF-8"?>), a single root element, and a configurable number of repeated record elements. Each record carries an id attribute and a fixed set of child elements covering common data types: a name string, an email, an integer quantity, a decimal price, and an ISO 8601 date.

Crucially, all text content and attribute values are escaped against the five XML predefined entities so the result is always well-formed. Literal & becomes &amp;, < becomes &lt;, > becomes &gt;, " becomes &quot;, and ' becomes &apos;. The whole document is assembled and indented in the browser, so nothing is sent anywhere.

Tips and notes

  • Validate the output by pasting it into your parser or an online XML validator; it should parse without errors.
  • To build a SOAP payload, wrap the generated records in your namespace-qualified <soap:Body> element.
  • Increase the row count to stress-test streaming parsers and memory usage on large documents.
  • The escaping rules here are the XML 1.0 predefined entities; CDATA sections are not used so the output stays simple and predictable.

What the output looks like

For a root element named catalog and a record element named item, the generator produces something like:

<?xml version="1.0" encoding="UTF-8"?>
<catalog>
  <item id="1">
    <name>Alice Thornton</name>
    <email>[email protected]</email>
    <quantity>47</quantity>
    <price>19.99</price>
    <date>2024-03-15</date>
  </item>
  <item id="2">
    <name>Marcus Webb</name>
    <email>[email protected]</email>
    <quantity>12</quantity>
    <price>5.49</price>
    <date>2024-04-02</date>
  </item>
</catalog>

This document is valid XML 1.0 and parses cleanly in any conformant parser, including Python’s xml.etree.ElementTree, Java’s SAX/DOM parsers, and .NET’s XmlDocument.

Common uses for generated XML test data

SOAP service testing — Most SOAP frameworks accept a bare <soap:Body> containing your service’s request type. The generated records serve as the inner data structure that the SOAP envelope wraps. Generate the records, drop them inside your SOAP template, and send them against a staging endpoint.

XML schema (XSD) validation — When developing or debugging an XSD, you need valid instance documents to validate against. Generating a handful of records with mixed-value data tests that required elements are present, optional ones are tolerated, and type restrictions (integer ranges, date formats) pass the schema.

SAX and streaming parser testing — SAX parsers process XML as a stream of events rather than loading the whole document into memory. Generating a large XML file (hundreds or thousands of records) lets you verify that your event handler accumulates state correctly without leaking memory or losing records mid-stream.

Legacy data migration — When migrating data from an old system that exports XML, you often need sample source files to test your import pipeline before the live export runs. The generator provides a structurally valid substitute while you build and validate the importer.