@@ -365,54 +365,6 @@ impl<R: BufRead> Reader<R> {
365365 buf. clear( ) ;
366366 } ) )
367367 }
368-
369- /// Reads optional text between start and end tags.
370- ///
371- /// If the next event is a [`Text`] event, returns the decoded and unescaped content as a
372- /// `String`. If the next event is an [`End`] event, returns the empty string. In all other
373- /// cases, returns an error.
374- ///
375- /// Any text will be decoded using the XML encoding specified in the XML declaration (or UTF-8
376- /// if none is specified).
377- ///
378- /// # Examples
379- ///
380- /// ```
381- /// # use pretty_assertions::assert_eq;
382- /// use quick_xml::Reader;
383- /// use quick_xml::events::Event;
384- ///
385- /// let mut xml = Reader::from_reader(b"
386- /// <a><b></a>
387- /// <a></a>
388- /// " as &[u8]);
389- /// xml.trim_text(true);
390- ///
391- /// let expected = ["<b>", ""];
392- /// for &content in expected.iter() {
393- /// match xml.read_event_into(&mut Vec::new()) {
394- /// Ok(Event::Start(ref e)) => {
395- /// assert_eq!(&xml.read_text_into(e.name(), &mut Vec::new()).unwrap(), content);
396- /// },
397- /// e => panic!("Expecting Start event, found {:?}", e),
398- /// }
399- /// }
400- /// ```
401- ///
402- /// [`Text`]: Event::Text
403- /// [`End`]: Event::End
404- pub fn read_text_into ( & mut self , end : QName , buf : & mut Vec < u8 > ) -> Result < String > {
405- let s = match self . read_event_into ( buf) {
406- Err ( e) => return Err ( e) ,
407-
408- Ok ( Event :: Text ( e) ) => e. unescape ( ) ?. into_owned ( ) ,
409- Ok ( Event :: End ( e) ) if e. name ( ) == end => return Ok ( "" . to_string ( ) ) ,
410- Ok ( Event :: Eof ) => return Err ( Error :: UnexpectedEof ( "Text" . to_string ( ) ) ) ,
411- _ => return Err ( Error :: TextNotFound ) ,
412- } ;
413- self . read_to_end_into ( end, buf) ?;
414- Ok ( s)
415- }
416368}
417369
418370impl Reader < BufReader < File > > {
0 commit comments