xml fix REPORT

This commit is contained in:
Lennart
2025-01-04 20:18:05 +01:00
parent a304714de8
commit 3a05671359
2 changed files with 32 additions and 1 deletions

View File

@@ -175,7 +175,8 @@ impl Enum {
}
Event::Comment(_) => { /* ignore */ }
Event::Decl(_) => {
return Err(::rustical_xml::XmlDeError::UnsupportedEvent("Declaration"));
/* ignore */
// return Err(::rustical_xml::XmlDeError::UnsupportedEvent("Declaration"));
}
Event::PI(_) => {
return Err(::rustical_xml::XmlDeError::UnsupportedEvent("Processing instruction"));

View File

@@ -256,3 +256,33 @@ fn test_xml_values() {
}
);
}
#[test]
fn test_struct_xml_decl() {
#[derive(Debug, XmlDeserialize, XmlRootTag, PartialEq)]
#[xml(root = b"document")]
struct Document {
child: Child,
}
#[derive(Debug, XmlDeserialize, PartialEq, Default)]
struct Child {
#[xml(ty = "text")]
text: String,
}
let doc = Document::parse_str(
r#"
<?xml version="1.0" encoding="utf-8"?>
<document><child>Hello!</child></document>"#,
)
.unwrap();
assert_eq!(
doc,
Document {
child: Child {
text: "Hello!".to_owned()
}
}
);
}