Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't acess methods in BytesText #744

Closed
lucasmolinari opened this issue May 11, 2024 · 2 comments
Closed

Can't acess methods in BytesText #744

lucasmolinari opened this issue May 11, 2024 · 2 comments
Labels

Comments

@lucasmolinari
Copy link

Using quick-xml = "0.31.0", in the following code:

    let mut reader = Reader::from_str(xml); //xml is an &str
    let mut buf = Vec::new();

    loop {
        match reader.read_event_into(&mut buf){
            Err(e) => panic!("Error at position {}: {:?}", reader.buffer_position(), e),
            Ok(Event::Eof) => break,
            Ok(Event::Start(ref e)) => println!("Found Start: {:?}", String::from_utf8_lossy(e)),
            Ok(Event::End(ref e)) => println!("Found End: {:?}", String::from_utf8_lossy(e)),
            Ok(Event::Text(e)) => {
                println!("{}", e.name());
        }
        _ => {}
        };
    }

Rust doesn't compile with the error:

error[E0599]: no method named `name` found for struct `BytesText<'_>` in the current scope
  --> src\main.rs:79:34
   |
79 |                 println!("{}", e.name());
   |                                  ^^^^ method not found in `BytesText<'_>`

@Mingun
Copy link
Collaborator

Mingun commented May 11, 2024

Yes, because BytesText has no such method, it represents the text (in opposite to markup) of XML. You probably confused it with BytesStart or BytesEnd.

@lucasmolinari
Copy link
Author

You are right, sorry for that :/

@Mingun Mingun closed this as completed May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants