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 fn enable_attributes_sorting(&mut self)
pub fn enable_attributes_sorting(&mut self)
Enables attributes sorting.
Sourcepub fn disable_attributes_sorting(&mut self)
pub 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: XMLElement) -> Result<()>
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
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 referenced XMLElement to
Auto Trait Implementations§
impl Freeze for XMLElement
impl RefUnwindSafe for XMLElement
impl Send for XMLElement
impl Sync for XMLElement
impl Unpin 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