Struct xml_builder::XMLElement

source ·
pub struct XMLElement { /* private fields */ }
Expand description

Structure representing an XML element field.

Implementations§

source§

impl XMLElement

source

pub fn new(name: &str) -> Self

Instantiates a new XMLElement object.

Arguments
  • name - A string slice that holds the name of the XML element.
source

pub fn enable_attributes_sorting(&mut self)

Enables attributes sorting.

source

pub fn disable_attributes_sorting(&mut self)

Disables attributes sorting.

source

pub fn add_attribute(&mut self, name: &str, value: &str)

Adds the given name/value attribute to the XMLElement.

Arguments
  • name - A string slice that holds the name of the attribute
  • value - A string slice that holds the value of the attribute
source

pub fn add_child(&mut self, element: XMLElement) -> Result<()>

Adds a new XMLElement child object to the references XMLElement.

Raises XMLError if trying to add a child to a text XMLElement.

Arguments
  • element - A XMLElement object to add as child
source

pub fn add_text(&mut self, text: String) -> Result<()>

Adds text content to a XMLElement object.

Raises XMLError if trying to add text to a non-empty object.

Arguments
  • text - A string containing the text to add to the object
source

pub fn render<W: Write>( &self, writer: &mut W, should_sort: bool, should_indent: bool ) -> Result<()>

Renders an XMLElement object into the specified writer implementing Write trait.

Does not take ownership of the object.

Arguments
  • writer - An object to render the referenced XMLElement to

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.