Struct xml::reader::EventReader
source · pub struct EventReader<R: Read> { /* private fields */ }
Expand description
A wrapper around an std::io::Read
instance which provides pull-based XML parsing.
Implementations§
source§impl<R: Read> EventReader<R>
impl<R: Read> EventReader<R>
sourcepub fn new(source: R) -> EventReader<R>
pub fn new(source: R) -> EventReader<R>
Creates a new reader, consuming the given stream.
sourcepub fn new_with_config(
source: R,
config: impl Into<ParserConfig2>
) -> EventReader<R>
pub fn new_with_config( source: R, config: impl Into<ParserConfig2> ) -> EventReader<R>
Creates a new reader with the provded configuration, consuming the given stream.
sourcepub fn next(&mut self) -> Result<XmlEvent>
pub fn next(&mut self) -> Result<XmlEvent>
Pulls and returns next XML event from the stream.
If returned event is XmlEvent::Error
or XmlEvent::EndDocument
, then
further calls to this method will return this event again.
sourcepub fn skip(&mut self) -> Result<()>
pub fn skip(&mut self) -> Result<()>
Skips all XML events until the next end tag at the current level.
Convenience function that is useful for the case where you have encountered a start tag that is of no interest and want to skip the entire XML subtree until the corresponding end tag.
pub fn source(&self) -> &R
pub fn source_mut(&mut self) -> &mut R
sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Unwraps this EventReader
, returning the underlying reader.
Note that this operation is destructive; unwrapping the reader and wrapping it
again with EventReader::new()
will create a fresh reader which will attempt
to parse an XML document from the beginning.
source§impl<'r> EventReader<&'r [u8]>
impl<'r> EventReader<&'r [u8]>
sourcepub fn from_str(source: &'r str) -> EventReader<&'r [u8]>
pub fn from_str(source: &'r str) -> EventReader<&'r [u8]>
A convenience method to create an XmlReader
from a string slice.
Trait Implementations§
source§impl<R: Read> IntoIterator for EventReader<R>
impl<R: Read> IntoIterator for EventReader<R>
source§impl<B: Read> Position for EventReader<B>
impl<B: Read> Position for EventReader<B>
source§fn position(&self) -> TextPosition
fn position(&self) -> TextPosition
Returns the position of the last event produced by the reader.