My XML data :
<?xml version="1.0" encoding="utf-8"?>
<feed
xmlns="http://ift.tt/r5ut6F"
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 \n", s.Link, s.Title)
}
Live demo at http://ift.tt/1M5qPbn
No comments:
Post a Comment