Export a batch of sample person records — generated server-side — as structured XML: a root <People> element wrapping one <Person> per record, with each property as a child element. XML remains common in enterprise integrations, SOAP-era systems, and tools that validate against XSD rather than JSON Schema.
How it works
peopleToXml recursively maps object fields to tagged elements, escaping &, <, >, and quotes inside text nodes. Arrays repeat the same element name; nested objects become nested tags (for example municipality fields under their parent). The document is a single well-formed XML string without an XML declaration unless you add one yourself downstream.
When to use it
- Feed legacy importers that only accept XML person lists
- Demonstrate XML escaping with names containing
&or< - Compare hierarchical markup against the flat CSV sibling export
Limitations
Attribute-style XML is not used—everything is element content. Very deep nesting mirrors the person model and may surprise simple XPath authors. There is no XSD attached; consumers must tolerate the element set. Escaping protects markup but does not validate business rules.
Example
A minimal person fragment looks like:
<People><Person><firstName>Ada</firstName><lastName>Lovelace</lastName><gender>F</gender><birthDate>1815-12-10</birthDate><email>ada@example.com</email></Person></People>
Parsers reading /People/Person/firstName recover Ada.