pub fn from_bytes_with_options<T: FromXml>(
buf: &[u8],
opts: Options,
) -> Result<T, Error>Expand description
§Parse a value from a byte slice with specific parser options.
This is the same as from_bytes, 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;
assert_eq!(
Foo { a: "some-value".to_owned() },
from_bytes_with_options(
b"<foo xmlns='urn:example' a='some-value'><!-- comment --></foo>",
opts,
).unwrap(),
);