title: How to deserialise a number from an XML attribute using serde?
body: <p>I want to deserialize a number (for example, <code>u32</code>) from an XML attribute.</p>
  
  <pre><code>#[macro_use]
  extern crate serde_derive;
  extern crate serde;
  extern crate serde_xml_rs as serde_xml;
  
  
  #[derive(Deserialize, Debug)]
  #[serde(rename = "objects")]
  pub struct Objects {
      pub foo: u32
  }
  
  fn main() {
      let result_string = r#"&lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;objects foo="42"&gt;&lt;/objects&gt;"#;
      let deserialized: Objects= serde_xml::deserialize(result_string.as_bytes()).expect("Parse error!");
  }
  </code></pre>
  
  <p>But after execution, I get the following error</p>
  
  <pre><code>thread 'main' panicked at 'Parse error!: invalid type: string "42", expected u32'
  </code></pre>
  
  <p>I know about <code>#[serde(deserialize_with="...")]</code> annotation, but is there an easier way, (for example use <code>serde_xml_rs</code> crate)?</p>