pub fn read_string(self) -> Result<String, VisitorError> {
        // TODO: consider reimplementing via `impl ElementVisitor for String`.
        // Might decrease this crate's code size.
        let mut out = String::new();
        loop {
            debug_assert_eq!(self.stack_pos, self.reader.stack().len() - 1);
            match self.reader.next().map_err(VisitorError::Propagate)? {
                (Event::StartElement { .. }, pos) => {
                    let stack = self.reader.stack();
                    let child = stack.last().unwrap();
                    return Err(VisitorError::Propagate(Error::msg(
                        stack,
                        pos,
                        format!("Unexpected element {} in string", &child.name),
                    )));
                }
                (Event::EndElement { .. }, _pos) => break,
                (Event::Characters(str), _pos) => {
                    if out.is_empty() {
                        out = str;
                    } else {
                        out.push_str(&str);
                    }
                }
            }
        }
        Ok(out)
    }
/// Reads all attributes and elements to the given string (or empty).
///
/// Returns an error if there are any child elements.
///
/// *TODO:* should this also return an error if there are attributes?
/// XML Schema simple types do that, so we should probably match it?
Reads all attributes and elements to the given string (or empty).
Returns an error if there are any child elements.

should this also return an error if there are attributes.
Reads all attributes and elements to the given string ( or empty ) . Returns an error if there are any child elements . should this also return an error if there are attributes .
pub fn read_string(self) -> Result<String, VisitorError> {
        // TODO: consider reimplementing via `impl ElementVisitor for String`.
        // Might decrease this crate's code size.
        let mut out = String::new();
        loop {
            debug_assert_eq!(self.stack_pos, self.reader.stack().len() - 1);
            match self.reader.next().map_err(VisitorError::Propagate)? {
                (Event::StartElement { .. }, pos) => {
                    let stack = self.reader.stack();
                    let child = stack.last().unwrap();
                    return Err(VisitorError::Propagate(Error::msg(
                        stack,
                        pos,
                        format!("Unexpected element {} in string", &child.name),
                    )));
                }
                (Event::EndElement { .. }, _pos) => break,
                (Event::Characters(str), _pos) => {
                    if out.is_empty() {
                        out = str;
                    } else {
                        out.push_str(&str);
                    }
                }
            }
        }
        Ok(out)
    }
pub fn read_string ( self ) -> Result < String , VisitorError > { // TODO: consider reimplementing via `impl ElementVisitor for String`. // Might decrease this crate's code size. let mut out = String :: new ( ) ; loop { debug_assert_eq ! ( self stack_pos self reader stack ( ) len ( ) 1 ) ; match self . reader . next ( ) . map_err ( VisitorError :: Propagate ) ? { ( Event :: StartElement { .. } , pos ) => { let stack = self . reader . stack ( ) ; let child = stack . last ( ) . unwrap ( ) ; return Err ( VisitorError :: Propagate ( Error :: msg ( stack , pos , format ! ( " " child name ) , ) ) ) ; } ( Event :: EndElement { .. } , _pos ) => break , ( Event :: Characters ( str ) , _pos ) => { if out . is_empty ( ) { out = str ; } else { out . push_str ( & str ) ; } } } } Ok ( out ) }
Reads all attributes and elements to the given string (or empty).
Reads all attributes and elements to the given string ( or empty ) .
self