[−][src]Trait confluence::rpser::xml::BuildElement
Helper trait for building xmltree::Element
.
Such convenience methods were not available in xmltree::Element
, so they are added
as a trait. To use them, you need to use this BuildElement
trait.
Example
extern crate xmltree; extern crate confluence; use xmltree::Element; use confluence::rpser::xml::BuildElement; fn main() { assert_eq!( Element::node("tag") .with_child( Element::node("hello").with_text("world") ) .to_string(), "<?xml version=\"1.0\" encoding=\"UTF-8\"?><tag><hello>world</hello></tag>" ); }
Required methods
fn cloned(&self) -> Self
The missing clone
implementation for xmltree::Element
.
fn node<S>(name: S) -> Self where
S: Into<String>,
S: Into<String>,
Create empty node.
fn with_name<S>(self, name: S) -> Self where
S: Into<String>,
S: Into<String>,
Modify node's name.
fn with_text<S>(self, text: S) -> Self where
S: Into<String>,
S: Into<String>,
Modify node's text.
fn with_attr<KS, VS>(self, key: KS, value: VS) -> Self where
KS: Into<String>,
VS: Into<String>,
KS: Into<String>,
VS: Into<String>,
Add attribute.
fn with_child(self, child: Self) -> Self
Add child.
fn with_children<I>(self, children: I) -> Self where
Self: Sized,
I: IntoIterator<Item = Self>,
Self: Sized,
I: IntoIterator<Item = Self>,
Add children.
fn with_children_from_iter<'r, I>(self, children: I) -> Self where
Self: 'r + Sized,
I: Iterator<Item = &'r Self>,
Self: 'r + Sized,
I: Iterator<Item = &'r Self>,
Add children from iterator.
fn to_string(&self) -> String
Convert to string (xml).
fn descend(self, path: &[&str]) -> Result<Element, Error>
Descend into specified child element, destroying the parent.
fn descend_first(self) -> Result<Element, Error>
Descend into first child element, destroying the parent.
fn get_at_path(&self, path: &[&str]) -> Result<Element, Error>
Get clone of child element at path.
fn as_long(&self) -> Result<i64, Error>
Extract the value of long
type from the text.
fn as_int(&self) -> Result<i32, Error>
Extract the value of int
type from the text.
fn as_boolean(&self) -> Result<bool, Error>
Extract the value of boolean
type from the text.
fn as_string(&self) -> Result<String, Error>
Extract the value of string
type from the text.
fn as_datetime(&self) -> Result<DateTime<Utc>, Error>
Extract the value of DateTime
type from the text.
Implementations on Foreign Types
impl BuildElement for Element
[src]
fn cloned(&self) -> Self
[src]
fn node<S>(name: S) -> Self where
S: Into<String>,
[src]
S: Into<String>,
fn with_name<S>(self, name: S) -> Self where
S: Into<String>,
[src]
S: Into<String>,
fn with_text<S>(self, text: S) -> Self where
S: Into<String>,
[src]
S: Into<String>,
fn with_attr<KS, VS>(self, key: KS, value: VS) -> Self where
KS: Into<String>,
VS: Into<String>,
[src]
KS: Into<String>,
VS: Into<String>,
fn with_child(self, child: Self) -> Self
[src]
fn with_children<I>(self, children: I) -> Self where
I: IntoIterator<Item = Self>,
[src]
I: IntoIterator<Item = Self>,
fn with_children_from_iter<'r, I>(self, children: I) -> Self where
I: Iterator<Item = &'r Self>,
[src]
I: Iterator<Item = &'r Self>,