pub struct XMLElement { /* private fields */ }Expand description
Structure representing an XML element field.
Implementations§
Source§impl XMLElement
impl XMLElement
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Instantiates a new XMLElement object.
§Arguments
name- A string slice that holds the name of the XML element.
Sourcepub const fn enable_attributes_sorting(&mut self)
pub const fn enable_attributes_sorting(&mut self)
Enables attributes sorting.
Sourcepub const fn disable_attributes_sorting(&mut self)
pub const fn disable_attributes_sorting(&mut self)
Disables attributes sorting.
Sourcepub fn add_attribute(&mut self, name: &str, value: &str)
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 attributevalue- A string slice that holds the value of the attribute
Sourcepub fn add_child(&mut self, element: Self) -> Result<()>
pub fn add_child(&mut self, element: Self) -> 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- AXMLElementobject to add as child
Sourcepub fn add_text(&mut self, text: String) -> Result<()>
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
Sourcepub fn render<W: Write>(
&self,
writer: &mut W,
should_sort: bool,
should_indent: bool,
should_break_lines: bool,
should_expand_empty_tags: bool,
) -> Result<()>
pub fn render<W: Write>( &self, writer: &mut W, should_sort: bool, should_indent: bool, should_break_lines: bool, should_expand_empty_tags: 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 referencedXMLElementto
Trait Implementations§
Source§impl Clone for XMLElement
impl Clone for XMLElement
Source§fn clone(&self) -> XMLElement
fn clone(&self) -> XMLElement
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for XMLElement
impl RefUnwindSafe for XMLElement
impl Send for XMLElement
impl Sync for XMLElement
impl Unpin for XMLElement
impl UnsafeUnpin for XMLElement
impl UnwindSafe for XMLElement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more