diff --git a/crates/xml/derive/src/xml_enum.rs b/crates/xml/derive/src/xml_enum.rs index c6b3f2c..be0decc 100644 --- a/crates/xml/derive/src/xml_enum.rs +++ b/crates/xml/derive/src/xml_enum.rs @@ -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")); diff --git a/crates/xml/tests/de_struct.rs b/crates/xml/tests/de_struct.rs index 04bf581..1f782d6 100644 --- a/crates/xml/tests/de_struct.rs +++ b/crates/xml/tests/de_struct.rs @@ -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#" + + Hello!"#, + ) + .unwrap(); + assert_eq!( + doc, + Document { + child: Child { + text: "Hello!".to_owned() + } + } + ); +}