from_reader_with_options

Function from_reader_with_options 

Source
pub fn from_reader_with_options<T: FromXml, R: BufRead>(
    r: R,
    options: Options,
) -> Result<T>
Available on crate feature std only.
Expand description

§Parse a value using a specific parser config

This is the same as from_reader, except that the rxml parser [Options][rxml::Options] can be specified explicitly.

§Example

#[derive(FromXml, PartialEq, Debug)]
#[xml(namespace = "urn:example", name = "foo")]
struct Foo {
    #[xml(attribute)]
    a: String,
}

let mut opts = rxml::Options::default();
opts.comments = rxml::parser::CommentMode::Discard;
// let file = .. // containing XML comments
assert_eq!(
    Foo { a: "some-value".to_owned() },
    from_reader_with_options(BufReader::new(file), opts).unwrap(),
);