Struct inline_xml::Document
source · pub struct Document {
pub root: Tag,
pub xml_decl_attrs: Vec<(String, String)>,
pub doctype: Option<String>,
}Expand description
An XML document with metadata.
Example
use inline_xml::*;
fn main() {
let xml = xml! {
<html>
<h1>Example Document</h1>
<p>"This is an example document."</p>
</html>
};
let doc = xml
.into_document()
.expect("Failed to create XML document.")
.with_xml_version("1.0")
.with_xml_encoding("UTF-8")
.with_xml_attr("standalone", "yes")
.with_doctype("html");
println!("{doc}");
}Fields§
§root: Tag§xml_decl_attrs: Vec<(String, String)>§doctype: Option<String>Implementations§
source§impl Document
impl Document
sourcepub fn with_xml_attr(self, name: &str, value: impl Into<String>) -> Self
pub fn with_xml_attr(self, name: &str, value: impl Into<String>) -> Self
Pass an XML attribute.
Example
use inline_xml::*;
let doc = xml! { <root /> }
.into_document()
.expect("Failed to create XML document.")
.with_xml_attr("standalone", "yes");sourcepub fn with_xml_version(self, version: impl Into<String>) -> Self
pub fn with_xml_version(self, version: impl Into<String>) -> Self
Specify the XML version of this document.
sourcepub fn with_xml_encoding(self, encoding: impl Into<String>) -> Self
pub fn with_xml_encoding(self, encoding: impl Into<String>) -> Self
Specify the XML encoding of this document (probably “UTF-8”).
sourcepub fn with_doctype(self, doctype: impl Into<String>) -> Self
pub fn with_doctype(self, doctype: impl Into<String>) -> Self
Specify the document type (eg. “html”).