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>
*/

Implementations

Removes previous prefix if it exists, and attach new prefix.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.