#writer #minidom #extension #io-write

minidom_writer

Helper to write into a std::io::Write a minidom::Element

1 stable release

1.0.0 Apr 24, 2020

#78 in #io-write

Download history 56/week @ 2024-04-08 89/week @ 2024-04-15 80/week @ 2024-04-22 35/week @ 2024-04-29 72/week @ 2024-05-06 107/week @ 2024-05-13 88/week @ 2024-05-20 36/week @ 2024-05-27 70/week @ 2024-06-03 36/week @ 2024-06-10 39/week @ 2024-06-17 77/week @ 2024-06-24 43/week @ 2024-07-01 52/week @ 2024-07-08 49/week @ 2024-07-15 38/week @ 2024-07-22

184 downloads per month
Used in 2 crates

MIT license

10KB
119 lines

GitHub Action Status Latest Version

minidom_writer

Helper to write 'minidom::Element' into an XML. See documentation.


lib.rs:

Helper for minidom to write XML.

Description

The crate provides ElementWriter which can write an Element.

Example

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());

Dependencies

~1.5–2.1MB
~40K SLoC