xml/reader/parser/
inside_cdata.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use reader::events::XmlEvent;
use reader::lexer::Token;

use super::{Result, PullParser, State};

impl PullParser {
    pub fn inside_cdata(&mut self, t: Token) -> Option<Result> {
        match t {
            Token::CDataEnd => {
                self.lexer.enable_errors();
                let event = if self.config.cdata_to_characters {
                    None
                } else {
                    let data = self.take_buf();
                    Some(Ok(XmlEvent::CData(data)))
                };
                self.into_state(State::OutsideTag, event)
            }

            Token::Whitespace(_) => {
                t.push_to_string(&mut self.buf);
                None
            }

            _ => {
                self.inside_whitespace = false;
                t.push_to_string(&mut self.buf);
                None
            }
        }
    }
}