Skip to content

jac3km4/roxmltree-serde

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

roxmltree-serde

Serde XML Deserializer based on roxmltree with support for zero-copy parsing.

usage

#[derive(Debug, Deserialize)]
pub struct Channel<'a> {
    // regular field, accepts either an attribute (title="Tech News")
    // or a child text node (<title>Tech News</title>)
    pub title: &'a str,
    // accepts multiple child nodes with tag <item>
    #[serde(rename = "item", default)]
    pub items: Vec<Item<'a>>,
}

#[derive(Debug, Deserialize)]
pub struct Item<'a> {
    // optional attribute or child
    pub guid: Option<Guid<'a>>,
    // accepts multiple child nodes with tag 'content' prefixed by a namespace
    #[serde(rename = "$ns:content", default)]
    pub media: Vec<MediaContent<'a>>,
}

#[derive(Debug, Deserialize)]
pub struct Guid<'a> {
    // parses the contents of node as text (<guid>this</guid>)
    #[serde(rename = "$text")]
    pub value: &'a str,
}

Complete examples can be found in the tests.

About

Serde XML Deserializer based on roxmltree

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages