Crate xml_dom
A Rust crate providing a reasonably faithful implementation of the W3C Document Object Model Core, Level 2.
This crate provides a trait-based implementation of the DOM with minimal changes to the style and semantics defined in the Level 2 specification. The specific mapping from the IDL in the specification is described in the documentation, however from a purely style point of view the implementation has the following characteristics:
- It maintains a reasonable separation between the node type traits and the tree implementation using opaque Node reference types.
- Where possible the names from IDL are used with minimal conversion, however some redundant
suffixes (
_data
,_node
) have been reduced for brevity/clarity. - This leads to a replication of the typical programmer experience where casting between the
node traits is required. This is supported by the
xml_dom::convert
module.
Example
use *;
use *;
let implementation = get_implementation;
let mut document_node =
implementation.create_document.unwrap;
let document = as_document.unwrap;
let root = document.create_element.unwrap;
let mut root_node = document_node.append_child.unwrap;
let root = as_element_mut.unwrap;
root.set_attribute;
root.set_attribute;
let xml = document_node.to_string;
println!;
Changes
Version 0.1.0
- Focus on modeling as traits, not all functions actually implemented.
- Note, this is NOT YET ready for production usage.
TODO
- Currently does not support
DocumentFragment
,Entity
,EntityReference
, orNotation
. - Not intending to be schema-aware, so
Document::get_element_by_id
always returnsNone
. - A lot of required methods are still
unimplemented!()
. - Intend to add reader features to de-serialize using crate
quick_xml
.