end calls

This commit is contained in:
Shautvast 2025-07-19 08:48:44 +02:00
parent 8cd82fffbd
commit 2b68c7dafb
2 changed files with 13 additions and 6 deletions

View file

@ -33,14 +33,17 @@ impl<'a> SAXParser<'a> {
}
fn parse_elements(&mut self) -> anyhow::Result<()> {
while self.position < self.xml.len() {
if self.current == '<' {
self.advance()?;
if self.next_char()? != '/' {
if self.current != '/' {
self.parse_start_element()?;
} else {
self.parse_end_element()?;
}
}
}
self.handler.end_document();
Ok(())
}
@ -55,6 +58,8 @@ impl<'a> SAXParser<'a> {
}
self.handler.start_element("", name.as_str(), "", atts);
self.skip_whitespace()?;
self.expect_char('>')?;
Ok(())
}

View file

@ -58,6 +58,8 @@ mod tests {
assert!(testhandler.start_element_called);
assert!(!testhandler.elements.is_empty());
assert_eq!(testhandler.elements[0], r#"<element a="1">"#);
assert!(testhandler.end_element_called);
assert!(testhandler.end_document_called);
}
}