I am receiving an xml file from a 3rd party which has an HTML element within one of the XML tags. I cannot work out how to unmarshal this to get the href URL.
XML Example:
<SOME_HTML>
<a href="http://www.google.com" target="_blank">
google</a>
</SOME_HTML>
This is as far as I have got so far but not adding anything to the struct:
type Href struct {
Link string `xml:"href"`
}
type Link struct {
URL []Href `xml:"a"`
}
type XmlFile struct {
HTMLTag []Link `xml:"SOME_HTML"`
}
myFile := []byte(`<?xml version="1.0" encoding="utf-8"?>
<SOME_HTML>
<a href="http://www.google.com" target="_blank">
google</a>
</SOME_HTML>`)
var output XmlFile
err := xml.Unmarshal(myFile, &output)
fmt.Println(output) // {[]}