#extension #writer #minidom #io-write

minidom_writer

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

1 stable release

1.0.0 Apr 24, 2020

#4 in #minidom

Download history 38/week @ 2024-07-22 57/week @ 2024-07-29 73/week @ 2024-08-05 81/week @ 2024-08-12 44/week @ 2024-08-19 64/week @ 2024-08-26 65/week @ 2024-09-02 66/week @ 2024-09-09 72/week @ 2024-09-16 81/week @ 2024-09-23 41/week @ 2024-09-30 1/week @ 2024-10-07 35/week @ 2024-10-14 11/week @ 2024-10-28 50/week @ 2024-11-04

96 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