#xml #xmpp #quick-xml #dom #minidom #subset #targeting

minidom-14

A small, simple DOM implementation on top of quick-xml, targeting the subset of XML useful for XMPP

4 releases (breaking)

0.17.0 Oct 4, 2024
0.16.0 Mar 22, 2023
0.15.0 Mar 22, 2023
0.14.0 Mar 22, 2023

#683 in Network programming

Download history 2/week @ 2024-09-06 13/week @ 2024-09-13 103/week @ 2024-09-20 69/week @ 2024-09-27 181/week @ 2024-10-04 25/week @ 2024-10-11 10/week @ 2024-10-18 5/week @ 2024-10-25 22/week @ 2024-11-01 33/week @ 2024-11-08 21/week @ 2024-11-15 9/week @ 2024-11-22 5/week @ 2024-11-29

79 downloads per month
Used in 2 crates (via dae-parser)

MPL-2.0 license

81KB
1.5K SLoC

minidom-14

This is a fork of minidom 0.14, which is exclusively receiving dependency upgrades and bugfixes. This crate exists because minidom 0.15 changed its API significantly and dropped support for quick-xml.


lib.rs:

A minimal DOM crate built on top of quick-xml, targeting exclusively the subset of XML useful for XMPP.

This library exports an Element struct which represents a DOM tree.

Example

Run with cargo run --example articles. Located in examples/articles.rs.

extern crate minidom;

use minidom::Element;

const DATA: &'static str = r#"<articles xmlns="article">
    <article>
        <title>10 Terrible Bugs You Would NEVER Believe Happened</title>
        <body>
            Rust fixed them all. &lt;3
        </body>
    </article>
    <article>
        <title>BREAKING NEWS: Physical Bug Jumps Out Of Programmer's Screen</title>
        <body>
            Just kidding!
        </body>
    </article>
</articles>"#;

const ARTICLE_NS: &'static str = "article";

#[derive(Debug)]
pub struct Article {
    title: String,
    body: String,
}

fn main() {
    let root: Element = DATA.parse().unwrap();

    let mut articles: Vec<Article> = Vec::new();

    for child in root.children() {
        if child.is("article", ARTICLE_NS) {
            let title = child.get_child("title", ARTICLE_NS).unwrap().text();
            let body = child.get_child("body", ARTICLE_NS).unwrap().text();
            articles.push(Article {
                title: title,
                body: body.trim().to_owned(),
            });
        }
    }

    println!("{:?}", articles);
}

Usage

To use minidom, add this to your Cargo.toml under dependencies:

minidom = "*"

Dependencies

~1.5MB
~21K SLoC