My XML data :
<?xml version="1.0" encoding="utf-8"?>
<feed
xmlns="http://www.w3.org/2005/Atom"
xmlns:idx="urn:atom-extension:indexing">
<entry>
<title type="html">Some Title</title>
<link href="https://www.google.com"></link>
</entry>
</feed>
I want to parse Each <entry>
with its <title>
& <link>
tag so far I have successfully parsed the title but no success with <link>
.
My Code :
type Entry struct {
XMLName xml.Name `xml:"entry"`
Link string `xml:"link"`
Title string `xml:"title"`
}
type Feed struct {
XMLName xml.Name `xml:"feed"`
Entries []Entry `xml:"entry"`
}
func (s Entry) String() string {
return fmt.Sprintf("\t Link : %s - Title : %s
", s.Link, s.Title)
}
Live demo at http://play.golang.org/p/hteQ5RuMco