diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index ed19a3e..f20be84 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -279,7 +279,7 @@ fn output_result_json_pretty(result: T) -> Result<()> { #[cfg(feature = "xml")] fn output_result_xml(result: T) -> Result<()> { use quick_xml::{ - events::{BytesEnd, BytesStart, BytesText, Event}, + events::{BytesDecl, BytesEnd, BytesStart, BytesText, Event}, Writer, }; use serde_json::Value; @@ -292,6 +292,9 @@ fn output_result_xml(result: T) -> Result<()> { // Initialize the XML writer with a new, empty vector to store the XML data. let mut writer = Writer::new(Vec::new()); + // Write the XML 1.1 declaration + writer.write_event(Event::Decl(BytesDecl::new("1.1", Some("utf-8"), None)))?; + // Define a recursive function `json_to_xml` to convert the JSON value into XML // format. The function takes a mutable reference to the XML writer, an // optional key as a string slice, and a reference to the JSON value to be