pub fn xml_to_abx(xml: &str) -> Result<Vec<u8>>Available on crate feature
xml only.Expand description
Encodes XML text as ABX bytes.
- Every attribute value is written as
AttributeValue::String: no type is inferred, soversion="3"stays a string. - The
<?xml ...?>declaration is dropped, andStartDocument/EndDocumentare added. - Entity references in text become
Event::EntityReference; in attribute values they are decoded. - Namespaces are not processed:
android:nameis a plain name.
§Errors
Returns AbxError::Xml if the XML is malformed, or
AbxError::ValueTooLong if a string is longer than 65,535 bytes.
§Examples
use android_abx::{AbxParser, AttributeValue, xml_to_abx};
let data = xml_to_abx(r#"<pkg name="com.example" version="3"/>"#)?;
let version = AbxParser::new(&data)?.find_attribute("pkg", "version")?;
assert_eq!(version, Some(AttributeValue::String("3".into())));