Skip to main content

xml_escape

Function xml_escape 

Source
pub fn xml_escape(s: &str) -> String
Expand description

Escape a string for safe inclusion in XML content.

Replaces &, <, >, ", and ' with their XML entity references.

ยงExamples

use rustack_s3_core::utils::xml_escape;

assert_eq!(xml_escape("a<b>c"), "a&lt;b&gt;c");
assert_eq!(xml_escape("x&y"), "x&amp;y");
assert_eq!(xml_escape("hello"), "hello");