I have a huge xml in a variable and a function to decode this xml. I can't use unmarshal because at a certain momment I need to read an element and add it immediately in the db.
Example:
db := mongo.Connect()
decoder := xml.NewDecoder(resp.Body)
defer resp.Body.Close()
for {
token, _ := decoder.Token()
if token == nil {
break
}
switch se := token.(type) {
case xml.StartElement:
...
}
But now I need to read from a string. So I don't have the resp.Body anymore but a string. The NewDecoder() function receives an io.Reader, so I think I can in read from a stream. How can I do this??