xavier-internal 0.1.7

Internal module of Xavier. Xavier is a lightweight and versatile XML parsing library designed to streamline the process of handling XML data with ease and efficiency.
Documentation

#[macro_export]
macro_rules! cdata {
    ($expr:expr) => { format!("<![CDATA[{}]]>", $expr).to_string() };
}

#[macro_export]
macro_rules! encode {
    ($expr:expr) => { xavier::serialize::encode::escape_xml($expr).to_string() };
}

#[macro_export]
macro_rules! comment {
    ($expr:expr) => { format!("<!--{}-->", xavier::serialize::escaping::escape_xml($expr)).to_string() };
}

pub fn escape_xml(input: &str) -> String {
    input
        .replace("&", "&amp;")
        .replace("<", "&lt;")
        .replace(">", "&gt;")
        .replace("\"", "&quot;")
        .replace("'", "&apos;")
}