Skip to main content

xml_depth

Function xml_depth 

Source
pub fn xml_depth(xml: &str) -> usize
Expand description

The deepest element nesting in xml, found by a quick scan without recursion, so it can run before the (recursive) XML parser.

It only has to be right for documents the parser (roxmltree) accepts, but it fails closed: markup it does not understand counts as infinitely deep. Comments, CDATA and processing instructions are skipped and quotes in tags are honoured. A <!DOCTYPE> (which usvg accepts) is skipped the way roxmltree reads it, but entities can expand to markup the scan never sees, so a DTD declaring any entity value with markup or references in it, or one roxmltree may read differently, counts as infinitely deep. Plain entities, such as the namespace URLs Adobe Illustrator declares, are fine.