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

Example with EventReader? #141

Closed
lumost opened this issue Sep 21, 2020 · 1 comment · Fixed by #163
Closed

Example with EventReader? #141

lumost opened this issue Sep 21, 2020 · 1 comment · Fixed by #163
Assignees

Comments

@lumost
Copy link

lumost commented Sep 21, 2020

Would it be possible to incude an example with an event reader? It's unclear how to deserialize from an event stream between the docs here and xml-rs.

@punkstarman punkstarman self-assigned this Sep 22, 2020
@punkstarman
Copy link
Collaborator

punkstarman commented Sep 22, 2020

It would. Thank you @lumost for the suggestion.

As a stopgap, basically the point of instantiating the EventReader yourself is to be able to choose the configuration options. By default, this crate activates trim_whitespace, whitespace_to_characters, cdata_to_characters, ignore_comments and coalesce_characters.

Once you have an EventReader you can deserialize using the following code.

use serde_xml_rs::de::Deserializer;

let result = T::deserialize(&mut Deserializer::new(event_reader));

where T is the type being deserialized to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants