Skip to main content

strip_xml_prolog

Function strip_xml_prolog 

Source
pub fn strip_xml_prolog(src: &str) -> String
Expand description

Remove the XML prolog (<?xml ... ?>) and DOCTYPE + leading comments so html5ever’s HTML5 parser doesn’t see tokens it doesn’t recognise. The caller is then free to hand the result to the HTML parser.

Repeats until no more prolog-like prefixes remain, so inputs with multiple headers (<?xml ?><!DOCTYPE><!-- generated-by -->) work without extra passes.