sikkom: maak gebruik van namespaces
This commit is contained in:
@@ -31,7 +31,7 @@ type ItemT struct {
|
|||||||
PubDate string `xml:"pubDate"`
|
PubDate string `xml:"pubDate"`
|
||||||
UnixTime int64 `xml:"unixTime"`
|
UnixTime int64 `xml:"unixTime"`
|
||||||
Guid string `xml:"guid"`
|
Guid string `xml:"guid"`
|
||||||
Link string `xml:"link"`
|
Link string `xml:"https://www.rssboard.org/rss-specification link"` // i.p.v. atom:link
|
||||||
Premium bool `xml:"premium"`
|
Premium bool `xml:"premium"`
|
||||||
Data []byte `xml:",innerxml"`
|
Data []byte `xml:",innerxml"`
|
||||||
}
|
}
|
||||||
@@ -94,9 +94,8 @@ func main() {
|
|||||||
p(err)
|
p(err)
|
||||||
p(resp.Body.Close())
|
p(resp.Body.Close())
|
||||||
|
|
||||||
b2 := bytes.ReplaceAll(
|
// zet de default namespace om onderscheid te kunnen maken met overige namespaces
|
||||||
bytes.ReplaceAll(body, []byte("<atom:"), []byte("<atom_")),
|
b2 := bytes.Replace(body, []byte("<rss"), []byte(`<rss xmlns="https://www.rssboard.org/rss-specification"`), 1)
|
||||||
[]byte("</atom:"), []byte("</atom_"))
|
|
||||||
|
|
||||||
var rss Rss
|
var rss Rss
|
||||||
p(xml.Unmarshal(b2, &rss))
|
p(xml.Unmarshal(b2, &rss))
|
||||||
|
|||||||
Reference in New Issue
Block a user