pub fn expect_text_or_end<B: BufRead>(
    key: &str,
    reader: &mut XmlReader<B>,
    buf: &mut Vec<u8>,
) -> Result<String> {
    match reader.read_event(buf)? {
        XmlEvent::Text(t) => {
            let text = t.unescape_and_decode(reader)?;
            buf.clear();
            expect_end(key, reader, buf)?;
            Ok(text)
        }
        XmlEvent::End(e) => {
            check_end(e, key, reader)?;
            Ok(String::new())
        }
        _ => Err(Error::MissingTextOrEndTag(key.to_string())),
    }
}
/// Expect either a text node or an end tag
Expect either a text node or an end tag
Expect either a text node or an end tag
pub fn expect_text_or_end<B: BufRead>(
    key: &str,
    reader: &mut XmlReader<B>,
    buf: &mut Vec<u8>,
) -> Result<String> {
    match reader.read_event(buf)? {
        XmlEvent::Text(t) => {
            let text = t.unescape_and_decode(reader)?;
            buf.clear();
            expect_end(key, reader, buf)?;
            Ok(text)
        }
        XmlEvent::End(e) => {
            check_end(e, key, reader)?;
            Ok(String::new())
        }
        _ => Err(Error::MissingTextOrEndTag(key.to_string())),
    }
}
pub fn expect_text_or_end < B : BufRead > ( key : & str , reader : & mut XmlReader < B > , buf : & mut Vec < u8 > , ) -> Result < String > { match reader . read_event ( buf ) ? { XmlEvent :: Text ( t ) => { let text = t . unescape_and_decode ( reader ) ? ; buf . clear ( ) ; expect_end ( key , reader , buf ) ? ; Ok ( text ) } XmlEvent :: End ( e ) => { check_end ( e , key , reader ) ? ; Ok ( String :: new ( ) ) } _ => Err ( Error :: MissingTextOrEndTag ( key . to_string ( ) ) ) , } }
Expect either a text node or an end tag
Expect either a text node or an end tag
key
&str
reader
&mut XmlReader<B>
buf
&mut Vec<u8>
key
&str
reader
&mut XmlReader<B>
buf
&mut Vec<u8>