end calls
This commit is contained in:
parent
8cd82fffbd
commit
2b68c7dafb
2 changed files with 13 additions and 6 deletions
|
|
@ -33,14 +33,17 @@ impl<'a> SAXParser<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_elements(&mut self) -> anyhow::Result<()> {
|
fn parse_elements(&mut self) -> anyhow::Result<()> {
|
||||||
|
while self.position < self.xml.len() {
|
||||||
if self.current == '<' {
|
if self.current == '<' {
|
||||||
self.advance()?;
|
self.advance()?;
|
||||||
if self.next_char()? != '/' {
|
if self.current != '/' {
|
||||||
self.parse_start_element()?;
|
self.parse_start_element()?;
|
||||||
} else {
|
} else {
|
||||||
self.parse_end_element()?;
|
self.parse_end_element()?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
self.handler.end_document();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,6 +58,8 @@ impl<'a> SAXParser<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.handler.start_element("", name.as_str(), "", atts);
|
self.handler.start_element("", name.as_str(), "", atts);
|
||||||
|
self.skip_whitespace()?;
|
||||||
|
self.expect_char('>')?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@ mod tests {
|
||||||
assert!(testhandler.start_element_called);
|
assert!(testhandler.start_element_called);
|
||||||
assert!(!testhandler.elements.is_empty());
|
assert!(!testhandler.elements.is_empty());
|
||||||
assert_eq!(testhandler.elements[0], r#"<element a="1">"#);
|
assert_eq!(testhandler.elements[0], r#"<element a="1">"#);
|
||||||
|
assert!(testhandler.end_element_called);
|
||||||
|
assert!(testhandler.end_document_called);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue