#writer #minidom #extension #io-write

minidom_writer

帮助将 minidom::Element 写入 std::io::Write

1 个稳定版本

1.0.0 2020年4月24日

#78 in #io-write

Download history 115/week @ 2024-04-03 96/week @ 2024-04-10 70/week @ 2024-04-17 58/week @ 2024-04-24 47/week @ 2024-05-01 89/week @ 2024-05-08 112/week @ 2024-05-15 54/week @ 2024-05-22 56/week @ 2024-05-29 53/week @ 2024-06-05 34/week @ 2024-06-12 45/week @ 2024-06-19 80/week @ 2024-06-26 38/week @ 2024-07-03 42/week @ 2024-07-10 42/week @ 2024-07-17

214 每月下载量
用于 2 crates

MIT 许可证

10KB
119 代码行

GitHub Action Status Latest Version

minidom_writer

帮助将 'minidom::Element' 写入 XML。见 文档


lib.rs:

minidom 提供帮助以写入 XML。

描述

该软件包提供 ElementWriter,可以写入 Element

示例

use minidom::{Element, Node};
use minidom_writer::ElementWriter;
use std::io::Cursor;

let subtag = Element::builder("ns:subtag")
    .attr("id", "my_subtag")
    .append(Node::Text(String::from("Some text")))
    .build();
let tag = Element::builder("tag")
    .attr("id", "my_tag")
    .append(subtag)
    .build();
let write = Cursor::new(Vec::new());
let mut element_writer = ElementWriter::plain(write);
element_writer.write(&tag).unwrap();
let expected = r#"<?xml version="1.0" encoding="UTF-8"?><tag id="my_tag"><ns:subtag id="my_subtag">Some text</ns:subtag></tag>"#;
assert_eq!(expected, String::from_utf8(element_writer.into_inner().into_inner()).unwrap());

依赖关系

~1.6–2.2MB
~41K SLoC