parse

Fold the tokens into a tree. Strict about nesting only where it can be: an end tag closes the nearest matching open element and is ignored when nothing matches, so a stray </b> cannot truncate the document.

This is the XML reading; HTML's implied end tags (<p>, <li>, table rows) are not applied, so use it for XML and SVG, not for tag soup.