A one-line note document
- XML
- <note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>
- Layout
- 2 spaces
Result Formatted XML: <note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Elements: 5
Maximum nesting depth: 2
Attributes: 0
Comments: 0
Output lines: 6
Input characters: 112
Output characters: 125
- Split the input into 14 tokens (tags, text, comments, declarations).
- Checked that every start tag has a matching end tag: 5 elements, nested 2 deep.
- Wrote each tag on its own line, indented one level per nesting depth; short text-only elements stay on one line.
The root and its four children land on six lines, each child indented two spaces with its text kept inline.