Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
XML parsing in Go
package main
import (
type Answer struct {
correct boolean
answer string
type Question struct {
question string
ask string
answerOne Answer
answerTwo Answer
answerThree Answer
answerFour Answer
func parseXML(input io.ReadWriter) ([]Question,error) {
output, err := xml.NewDecoder(Question).Decode(input)
if err != nil {
return nil, err
return output, nil
func main() {
res, err := http.Get("")
if err != nil {
log.Fatal("Error during GET request.")
res, er := parseXML(res)
if er != nil {
log.Fatal("Error during XML parsing")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.