Normalize: All whitespace between tags (> <) is removed to create a clean, compact base for processing.
Split by tags: The XML is split on each <tag> boundary. Opening, closing, and self-closing tags are detected separately.
Indent tracking: A counter increases on opening tags and decreases on closing tags. Each line is prefixed with the right number of spaces.
Minify does the opposite — strips all whitespace between tags, collapsing the entire document to a single line for compact transport.