diff --git a/instant-xml/src/lib.rs b/instant-xml/src/lib.rs index 5de63c4..66efba0 100644 --- a/instant-xml/src/lib.rs +++ b/instant-xml/src/lib.rs @@ -58,10 +58,13 @@ pub fn from_str<'xml, T: FromXml<'xml>>(input: &'xml str) -> Result { let id = context.element_id(&root)?; if !T::matches(id, None) { - return Err(Error::UnexpectedValue(format!( - "unexpected root element {} in namespace {}", - id.name, id.ns - ))); + return Err(Error::UnexpectedValue(match id.ns.is_empty() { + true => format!("unexpected root element {:?}", id.name), + false => format!( + "unexpected root element {:?} in namespace {:?}", + id.name, id.ns + ), + })); } let mut value = None; diff --git a/instant-xml/tests/de-ns.rs b/instant-xml/tests/de-ns.rs index a94ff4c..7fd41f3 100644 --- a/instant-xml/tests/de-ns.rs +++ b/instant-xml/tests/de-ns.rs @@ -40,7 +40,7 @@ fn default_namespaces() { "true" ), Err::(Error::UnexpectedValue( - "unexpected root element NestedDe in namespace WRONG".to_owned() + "unexpected root element \"NestedDe\" in namespace \"WRONG\"".to_owned() )) );