pub struct XMLStreamReader<'a, Resolver: EntityResolver = DefaultSAXHandler, Reporter: ErrorHandler = DefaultSAXHandler> { /* private fields */ }Implementations§
Source§impl<'a, Resolver: EntityResolver> XMLStreamReader<'a, Resolver>
impl<'a, Resolver: EntityResolver> XMLStreamReader<'a, Resolver>
Sourcepub fn last_error(&self) -> Option<&SAXParseError>
pub fn last_error(&self) -> Option<&SAXParseError>
Returns the most recently occurred warning, error, or fatal error.
If none occurred, returns None.
When no user-defined error handler is configured, this method can be used to catch errors
other than unrecoverable errors.
To catch all errors that occur during the parsing process, a user-defined error handler
must be configured.
Source§impl<'a, Resolver: EntityResolver, Reporter: ErrorHandler> XMLStreamReader<'a, Resolver, Reporter>
impl<'a, Resolver: EntityResolver, Reporter: ErrorHandler> XMLStreamReader<'a, Resolver, Reporter>
Sourcepub fn parse_uri(
&mut self,
uri: impl AsRef<URIStr>,
encoding: Option<&str>,
) -> Result<(), XMLError>
pub fn parse_uri( &mut self, uri: impl AsRef<URIStr>, encoding: Option<&str>, ) -> Result<(), XMLError>
Retrieves and parses the XML document specified by uri.
If retrieval or parsing of the XML document fails, an error is returned.
The preferred encoding can be specified using encoding.
Sourcepub fn parse_reader(
&mut self,
reader: impl Read + 'a,
encoding: Option<&str>,
uri: Option<&URIStr>,
) -> Result<(), XMLError>
pub fn parse_reader( &mut self, reader: impl Read + 'a, encoding: Option<&str>, uri: Option<&URIStr>, ) -> Result<(), XMLError>
The data read from reader is parsed as an XML document.
If parsing of the XML document fails, an error is returned.
The preferred encoding can be specified using encoding.
uri is treated as the document’s base URI. It is optional to set,
but may be required if the document being parsed references external resources.
Sourcepub fn parse_str(
&mut self,
xml: &str,
uri: Option<&URIStr>,
) -> Result<(), XMLError>
pub fn parse_str( &mut self, xml: &str, uri: Option<&URIStr>, ) -> Result<(), XMLError>
Parses xml as an XML document.
If parsing of the XML document fails, an error is returned.
Assumes the document is encoded in UTF-8.
uri is treated as the document’s base URI. It is optional to set,
but may be required if the document being parsed references external resources.
Sourcepub fn next_event<'b>(&'b mut self) -> Result<XMLEvent<'b>, XMLError>
pub fn next_event<'b>(&'b mut self) -> Result<XMLEvent<'b>, XMLError>
Advance the event until next markup or text data.
Sourcepub fn next_tag<'b>(&'b mut self) -> Result<XMLEvent<'b>, XMLError>
pub fn next_tag<'b>(&'b mut self) -> Result<XMLEvent<'b>, XMLError>
Advance the event until the tag-related event appears.
Sourcepub fn namespaces(&self) -> &NamespaceStack
pub fn namespaces(&self) -> &NamespaceStack
Current namespace stack.
Sourcepub fn locator(&self) -> Option<Arc<Locator>>
pub fn locator(&self) -> Option<Arc<Locator>>
Returns a valid locator if exists.
The returned locator is valid from after the StartDocument event until
before parsing ends due to the EndDocument event or a fatal error.
Outside the locator’s valid range, it returns None.
Sourcepub fn error_handler(&self) -> Option<&Reporter>
pub fn error_handler(&self) -> Option<&Reporter>
If a user-defined error handler is configured, it will be returned.
Sourcepub fn set_error_handler(&mut self, handler: Reporter) -> Option<Reporter>
pub fn set_error_handler(&mut self, handler: Reporter) -> Option<Reporter>
Configure a user-defined error handler. If a handler is already configured, return it.
Sourcepub fn take_error_handler(&mut self) -> Option<Reporter>
pub fn take_error_handler(&mut self) -> Option<Reporter>
If a user-defined error handler is configured, it will be returned.
The error handler will be unset.