无法解组值中带有空格的有效负载

I am using Golang to read an XML response. I am unable to read values with spaces properly.

Here is a gist: https://gist.github.com/anonymous/5825288

Is there a way to have xml.Unmarshal trim the value from <result> and then treat it as an int?

I.e.

<result>1<result> // no spaces, is marshalled correctly.  The resulting value in the struct is 1

but

<result> 1 </result>  // with spaces, is marshalled incorrectly as an int.  The resulting value in the struct for result is 0.

even in xml " 1 " this is a string and not a int, the parser cant parse this string to an int. so 0 is just the default int value,

if you change your code to :

err:= xml.Unmarshal([]byte(payload), &mt)
if err != nil {
  fmt.Println(err)
}

you will see that there was an error during parsing if your xml could have " 1 " as value, i recommend to use a string in your struct. or if there is a chance, tell the creator of the xml to only use int and not strings, where int are expected