Struct xml_doc::ElementBuilder [−][src]
pub struct ElementBuilder<'a> { /* fields omitted */ }
Expand description
An easy way to build a new element by chaining methods to add properties.
Call Element::build()
to start building.
To finish building, either call .finish()
or .push_to(parent)
which returns Element
.
Examples
use xml_doc::{Document, Element, Node};
let mut doc = Document::new();
let root = Element::build(&mut doc, "root")
.attribute("id", "main")
.attribute("class", "main")
.finish();
doc.push_root_node(root.as_node());
let name = Element::build(&mut doc, "name")
.text_content("No Name")
.push_to(root);
/* Equivalent xml:
<root id="main" class="main">
<name>No Name</name>
</root>
*/