Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
encoding/xml: cannot Unmarshal empty non-string nodes even with omitempty. #8333
Calling xml.Unmarshal will die with `error: strconv.ParseFloat: parsing "": invalid syntax` on an empty node unless you change it's type to string, even with `emptyempty` set. Example program: http://play.golang.org/p/VSk6TsuEPN Discussion: http://stackoverflow.com/questions/24602155/unmarshalling-optional-float64-field-returns-error-on-go/24602310#24602310 I realize one could use the UnmarshalXML interface, however I believe this is a bug in the xml package and it shouldn't try to use strconv on an empty node when omitempty is set.
An easy way to solve this issue of empty self closing tags or empty tag is to use
I am not a big fan of using packages for small stuff but this package have saved a lot of time for me
Here is how I am using this
Full credit to guregu/null