#extension #writer #minidom

minidom_writer

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

1 stable release

1.0.0 Apr 24, 2020

#29 in #writer

Download history 541/week @ 2022-03-10 459/week @ 2022-03-17 544/week @ 2022-03-24 533/week @ 2022-03-31 335/week @ 2022-04-07 159/week @ 2022-04-14 425/week @ 2022-04-21 296/week @ 2022-04-28 296/week @ 2022-05-05 281/week @ 2022-05-12 216/week @ 2022-05-19 245/week @ 2022-05-26 332/week @ 2022-06-02 204/week @ 2022-06-09 481/week @ 2022-06-16 244/week @ 2022-06-23

1,311 downloads per month
Used in transit_model

MIT license

9KB
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

~0.9–1.4MB
~30K SLoC