[−][src]Struct sxd_document::writer::Writer
Write a document, specifying some formatting options
For example, the default is to use single-quotes for attributes. To use
double quotes for attributes, you need to use set_single_quotes(false).
use sxd_document::{Package, writer::Writer}; // Create a new document let p = Package::new(); let doc = p.as_document(); let el = doc.create_element("hello"); el.set_attribute_value("a", "b"); doc.root().append_child(el); // Format the document as bytes let mut output = Vec::new(); Writer::new().set_single_quotes(false).format_document(&doc, &mut output); // Check that the output is correct let output_string = String::from_utf8(output).unwrap(); assert_eq!(output_string, r#"<?xml version="1.0"?><hello a="b"/>"#);
Methods
impl Writer[src]
pub fn new() -> Self[src]
Create a new Writer with default settings.
pub fn set_single_quotes(self, single_quotes: bool) -> Self[src]
Set whether single quotes should be used for writing a document.
impl Writer[src]
pub fn format_document<'d, W: ?Sized>(
&self,
doc: &'d Document<'d>,
writer: &mut W
) -> Result<()> where
W: Write, [src]
&self,
doc: &'d Document<'d>,
writer: &mut W
) -> Result<()> where
W: Write,
Formats a document into a Write
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> From<T> for T[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,