About the Random XML Generator
Parsers, XSLT sheets and SOAP style endpoints are easier to test against a document that has the shape of the real thing. Set a root element such as catalog, a repeating record element such as item, and choose how many records to emit. Each record is filled from the selected shape, so a Products document carries SKUs, categories and prices while a Log events document carries timestamps, levels and client addresses.
The Values as option decides the document style. Child elements produce the familiar nested form, Attributes squeeze every value onto the record tag for compact feeds, and the mixed setting keeps only the first field as an attribute, which is the usual way an identifier is written. Element names you type are sanitised to valid XML names: spaces and other illegal characters become hyphens and a leading digit is dropped, so the result always parses. Text values are escaped for the five predefined entities, so an ampersand in a company name arrives as &.
Indentation is two spaces, four spaces or a tab, and the XML declaration can be switched off when the fragment will be embedded in a larger document. Check the result in the XML validator, reshape it with the XML to JSON converter, or generate the same records as a spreadsheet file with the random CSV generator.
How to use
- Choose the number of Records and the shape of the data.
- Type the Root element and Record element names you need.
- Decide whether values become child elements or attributes, and set the indent.
- Copy the document or download it as an
.xmlfile.
Common questions
- Is the output well formed?
- Yes. Element names are sanitised, values are entity escaped and every record tag is closed, so the document parses in any XML reader.
- Can I control the field names?
- Yes. List them in Custom fields, for example sku, product, price, and use heading:type when the tag name should differ from the field type.
- Does it produce an XSD or a DTD?
- No. It emits instance documents only. Point your schema tool at the generated file if you need a schema inferred from it.
- Why do numbers arrive as text?
- XML has no native types without a schema, so prices and quantities are written as plain character data, which is what parsers expect.