We need to parse a huge XML file using Go. We'd like to use a SAX-like event based algorithm using xml.NewDecoder()
and decoder.Token()
library calls. We've created the appropriate struct types with XML annotations. Everything easy peasy so far.
Now, we go through the file and detect the xml.StartElement
tokens. And here comes the problem. We need to decode ONLY the attributes of this starting token and continue into its content. If we call token.DecodeElement()
the whole content is "decoded" or skipped in our scenario.
How to decode only the attributes of a specific StartElement
and continue to the element's body?