13 个版本 (5 个稳定)
1.2.3 | 2023 年 1 月 4 日 |
---|---|
1.2.2 | 2022 年 9 月 2 日 |
1.2.1 | 2022 年 8 月 22 日 |
0.7.0 | 2022 年 1 月 15 日 |
0.2.0 | 2017 年 3 月 30 日 |
#620 在 解析器实现
24,616 每月下载量
用于 26 个 包 (8 个直接使用)
235KB
5.5K SLoC
Rust 的 ElementTree
该库将 XML 解析为类似 Python ElementTree 的结构。它目前支持基本的读取和写入,具有相当好的命名空间支持,并能够检查文件。
不建议用于大型文档,因为整个文档将加载到内存中。然而,它非常适合处理配置文件等类似事物。
示例
let root = Element::from_reader(r#"<?xml version="1.0"?>
<root xmlns="tag:myns" xmlns:foo="tag:otherns">
<list a="1" b="2" c="3">
<item foo:attr="foo1"/>
<item foo:attr="foo2"/>
<item foo:attr="foo3"/>
</list>
</root>
"#.as_bytes()).unwrap();
let list = root.find("{tag:myns}list").unwrap();
for child in list.find_all("{tag:myns}item") {
println!("attribute: {}", child.get_attr("{tag:otherns}attr").unwrap());
}
许可证和链接
依赖项
~0.5–6MB
~14K SLoC