Struct elementtree::WriteOptions
source · pub struct WriteOptions { /* private fields */ }
Expand description
A struct that define write options.
Implementations§
source§impl WriteOptions
impl WriteOptions
pub fn new() -> WriteOptions
sourcepub fn set_xml_prolog(self, prolog: Option<XmlProlog>) -> Self
pub fn set_xml_prolog(self, prolog: Option<XmlProlog>) -> Self
Define which xml prolog will be displayed when rendering an Element.
Note that prolog is optional, an XML document with a missing prolog is well-formed but not valid.
See RFC: W3C XML 26 November 2008
sourcepub fn set_line_separator<I: Into<Cow<'static, str>>>(self, sep: I) -> Self
pub fn set_line_separator<I: Into<Cow<'static, str>>>(self, sep: I) -> Self
Line separator used to separate lines in formatted output. Default is "\n"
.
sourcepub fn set_indent_string<I: Into<Cow<'static, str>>>(self, indent: I) -> Self
pub fn set_indent_string<I: Into<Cow<'static, str>>>(self, indent: I) -> Self
A string which will be used for a single level of indentation. Default is " "
(two spaces).
sourcepub fn set_perform_indent(self, yes: bool) -> Self
pub fn set_perform_indent(self, yes: bool) -> Self
Whether or not the emitted document should be indented. Default is false.
The emitter is capable to perform automatic indentation of the emitted XML document. It is done in stream-like fashion and does not require the knowledge of the whole document in advance.
Sometimes, however, automatic indentation is undesirable, e.g. when you want to keep existing layout when processing an existing XML document. Also the indentiation algorithm is not thoroughly tested. Hence by default it is disabled.
sourcepub fn set_normalize_empty_elements(self, yes: bool) -> Self
pub fn set_normalize_empty_elements(self, yes: bool) -> Self
Whether or not to convert elements with empty content to empty elements. Default is true.
This option allows turning elements like <a></a>
(an element with empty content)
into <a />
(an empty element).
sourcepub fn set_cdata_to_characters(self, yes: bool) -> Self
pub fn set_cdata_to_characters(self, yes: bool) -> Self
Whether or not to emit CDATA events as plain characters. Default is false.
This option forces the emitter to convert CDATA events into regular character events, performing all the necessary escaping beforehand. This may be occasionally useful for feeding the document into incorrect parsers which do not support CDATA.
sourcepub fn set_pad_self_closing(self, yes: bool) -> Self
pub fn set_pad_self_closing(self, yes: bool) -> Self
Whether or not to automatically insert spaces before the trailing />
in self-closing
elements. Default is true.
This option is only meaningful if normalize_empty_elements
is true. For example, the
element <a></a>
would be unaffected. When normalize_empty_elements
is true, then when
this option is also true, the same element would appear <a />
. If this option is false,
then the same element would appear <a/>
.
sourcepub fn set_autopad_comments(self, yes: bool) -> Self
pub fn set_autopad_comments(self, yes: bool) -> Self
Whether or not to automatically insert leading and trailing spaces in emitted comments, if necessary. Default is true.
This is a convenience option in order for the user not to append spaces before and after
comments text in order to get more pretty comments: <!-- something -->
instead of
<!--something-->
.