Hello all,
I’am sorry for my english but i’am a french guy and my english is very bad.
I tried to parse an xml file with GO.
The xml file is a JIRA export
I use code find on the internet.
The simple file xml for exemple
JIRAand the go code
package main
import (
“encoding/xml”
“fmt”
“io/ioutil”
“os”
)
// Structure globale
type RSS struct {
XMLName xml.Name xml:"balise"
version string xml:"version,attr"
titre string xml:"title"
}
func main() {
// Open our xmlFile
xmlFile, err := os.Open("test.xml")
// if we os.Open returns an error then handle it
if err != nil {
fmt.Println(err)
}
fmt.Println("Successfully Opened users.xml")
// defer the closing of our xmlFile so that we can parse it later on
defer xmlFile.Close()
// read our opened xmlFile as a byte array.
byteValue, err := ioutil.ReadAll(xmlFile)
if err != nil {
fmt.Println(err)
}
// we initialize our Users array
var rss RSS
err = xml.Unmarshal(byteValue, &rss)
fmt.Println(rss)
}
when run the program, the result is just “{{ balise} }”
Why i don’t see the version and title in the reponse?
Thank you for your help, i search since 2 days but no answer for the moment