pub struct Reader<'a> { /* private fields */ }Expand description
A streaming parser of an XML 1.0 document with namespaces, read from a string.
Reader::next_event returns the events one by one; the reader keeps only the
open elements, the namespace declarations in scope and the attributes of the
current start tag. Names, and text without references or carriage returns, are
slices of the input. A document is well-formed when every event up to the final
None is read without error; events read before an error belong to a document
that is not.
Implementations§
Source§impl<'a> Reader<'a>
impl<'a> Reader<'a>
Sourcepub fn new(text: &'a str) -> Self
pub fn new(text: &'a str) -> Self
A reader of text with the default Limits. A byte order mark at the start
is skipped.
Sourcepub fn with_limits(text: &'a str, limits: Limits) -> Self
pub fn with_limits(text: &'a str, limits: Limits) -> Self
A reader of text with the given limits.
Sourcepub fn depth(&self) -> usize
pub fn depth(&self) -> usize
The number of open elements: after a Event::Start, its element included;
after an Event::End, its element still included.
Sourcepub fn text_pos(&self, offset: usize) -> TextPos
pub fn text_pos(&self, offset: usize) -> TextPos
The position of a byte offset of the text (see TextPos::at).
Sourcepub fn lookup_namespace(&self, prefix: &str) -> Option<&str>
pub fn lookup_namespace(&self, prefix: &str) -> Option<&str>
The namespace bound to prefix ("" for the default namespace) in the scope of
the innermost open element (the element of the last Event::Start or
Event::End included): None if there is none or if the default namespace is
undeclared. xml is always bound to XML_NAMESPACE and xmlns to
XMLNS_NAMESPACE.