Format and prettify nested XML documents to inspect data tags.
XML (eXtensible Markup Language) was designed in the late 1990s to store and transport data. Unlike JSON, which was born from JavaScript arrays and objects, XML was designed to be highly structured using nested tags (identical in syntax to HTML).
While JSON is heavily favored for modern Web APIs, XML remains the backbone of massive enterprise systems, banking protocols (like ISO 20022), SOAP APIs, and document storage formats (like Microsoft Office .docx files).
One of the main structural differences from JSON is that XML allows data to be stored in two distinct ways: Elements (tags) and Attributes.
<user id="123"> <name>Alice</name> </user>
In this example, id is an Attribute embedded directly into the opening tag, while name is a child Element containing a text node. This distinction allows for complex metadata organization that JSON cannot natively replicate.
XML is significantly heavier to parse than JSON. To format it, a parser must construct a full DOM (Document Object Model) tree in memory.
XML generated by automated systems is often "minified"—meaning all line breaks and spaces are aggressively removed to save network bandwidth. Formatting it requires walking the DOM tree and re-inserting consistent indentation (pretty-printing) so human engineers can debug it.
Which of the following is a key structural feature of XML that JSON lacks?