I am working on a xml parser which gets xml response from RSS feeds I happened to read some posts on json.Decode VS json.Unmarshal How to get JSON response from http.Get. In short:
- when data source is http.get which is streams we should use json.decoder, as it might be a very long json
- if response body is small enough, we can read it all into memory with ioutil.ReadAll and use json.Unmarshal. Also , json.Unmarshal is dealing with byte/string not stream
So I have the same question to xml decoding , does the same rule apply to http's xml response data ? Which means I should use xml.decode to parse http.get response , rather than ioutil.ReadAll and xml.Unmarshal ?