Skip to main content

decode_attribute_value

Function decode_attribute_value 

Source
pub fn decode_attribute_value(value: &[u8]) -> Result<Option<String>>
Expand description

Decodes an XML attribute’s raw value, undoing XML entity escaping — mirrors decode_text for attribute values. quick_xml’s own Attribute::from((&str, &str)) (used throughout this toolkit’s writers via BytesStart::push_attribute) escapes the value the exact same way BytesText::new does, so this is needed for the same reason.

Returns Ok(None) if value isn’t valid UTF-8, rather than an error — this crate’s readers treat a malformed attribute as simply absent rather than failing the whole document (see callers). An Err here specifically means the bytes were valid UTF-8 but contained a malformed or unknown entity reference, a stronger signal of a genuinely broken document.