pub struct Parser<'a> { /* private fields */ }
Expand description
A simple event callback-based XML parser.
Implementations§
source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
sourcepub fn addBeginHandler<F>(&mut self, tag: &'static str, handler: F)where
F: FnMut(&[String], &BytesStart<'_>) -> Result<(), Error> + 'a,
pub fn addBeginHandler<F>(&mut self, tag: &'static str, handler: F)where F: FnMut(&[String], &BytesStart<'_>) -> Result<(), Error> + 'a,
Add a callback for an opening tag. If the parser encounters an
opening tag whose name coincides with the value of tag
, it
calls handler
with the opening tag event. Self-closing tags
also trigger begin handlers.
sourcepub fn addEndHandler<F>(&mut self, tag: &'static str, handler: F)where
F: FnMut(&[String], &BytesEnd<'_>) -> Result<(), Error> + 'a,
pub fn addEndHandler<F>(&mut self, tag: &'static str, handler: F)where F: FnMut(&[String], &BytesEnd<'_>) -> Result<(), Error> + 'a,
Add a callback for an end tag. If the parser encounters an end
tag whose name coincides with the value of tag
(not
including the starting /
), it calls handler
with the end
tag event. Self-closing tags also trigger end handlers.
sourcepub fn addTextHandler<F>(&mut self, tag: &'static str, handler: F)where
F: FnMut(&[String], &str) -> Result<(), Error> + 'a,
pub fn addTextHandler<F>(&mut self, tag: &'static str, handler: F)where F: FnMut(&[String], &str) -> Result<(), Error> + 'a,
Add a callback for text element directly inside some tag. If
the parser encounters a text element where it’s enclosing tag
coincides with the value of tag
, it calls handler
with the
decoded text string.
Note that this does not mean the text needs to be the only or the last element in the enclosing tag.
sourcepub fn addTagHandler<F>(&mut self, tag: &'static str, handler: F)where
F: FnMut(&[String], &[u8]) -> Result<(), Error> + 'a,
pub fn addTagHandler<F>(&mut self, tag: &'static str, handler: F)where F: FnMut(&[String], &[u8]) -> Result<(), Error> + 'a,
Add a callback for a whole tag. If the parser encounters an
opening element (including self-closing tags) whose name
coincides with the value of tag
, it calls handler
with the
content of the whole tag, including the opening and the
closing tag. The parser then skips the whole tag.
This is useful if the user wants to delegate the parsing of a tag to another parser.