Fix Atom/RSS feed parsing due to changes in jteeuwen/go-pkg-xmlx.
Due to recent changes involving how values are dealt with in xmlx, update the RSS/Atom parsing. Instead of using the Value property of an xmlx Node, use the new GetValue function offered in PR jteeuwen/go-pkg-xmlx#15.
This commit is contained in:
parent
c173d50291
commit
20d050f908
6
atom.go
6
atom.go
|
@ -50,14 +50,14 @@ func (this *Feed) readAtom(doc *xmlx.Document) (err error) {
|
|||
if tn = node.SelectNode(ns, "subtitle"); tn != nil {
|
||||
ch.SubTitle = SubTitle{}
|
||||
ch.SubTitle.Type = tn.As("", "type")
|
||||
ch.SubTitle.Text = tn.Value
|
||||
ch.SubTitle.Text = tn.GetValue()
|
||||
}
|
||||
|
||||
if tn = node.SelectNode(ns, "generator"); tn != nil {
|
||||
ch.Generator = Generator{}
|
||||
ch.Generator.Uri = tn.As("", "uri")
|
||||
ch.Generator.Version = tn.As("", "version")
|
||||
ch.Generator.Text = tn.Value
|
||||
ch.Generator.Text = tn.GetValue()
|
||||
}
|
||||
|
||||
if tn = node.SelectNode(ns, "author"); tn != nil {
|
||||
|
@ -104,7 +104,7 @@ func (this *Feed) readAtom(doc *xmlx.Document) (err error) {
|
|||
i.Content.Type = tn.As("", "type")
|
||||
i.Content.Lang = tn.S("xml", "lang")
|
||||
i.Content.Base = tn.S("xml", "base")
|
||||
i.Content.Text = tn.Value
|
||||
i.Content.Text = tn.GetValue()
|
||||
}
|
||||
|
||||
if tn = item.SelectNode(ns, "author"); tn != nil {
|
||||
|
|
18
rss.go
18
rss.go
|
@ -46,7 +46,7 @@ func (this *Feed) readRss2(doc *xmlx.Document) (err error) {
|
|||
ch.Links = make([]Link, len(list))
|
||||
|
||||
for i, v := range list {
|
||||
ch.Links[i].Href = v.Value
|
||||
ch.Links[i].Href = v.GetValue()
|
||||
}
|
||||
|
||||
ch.Description = node.S(ns, "description")
|
||||
|
@ -63,12 +63,12 @@ func (this *Feed) readRss2(doc *xmlx.Document) (err error) {
|
|||
for i, v := range list {
|
||||
ch.Categories[i] = new(Category)
|
||||
ch.Categories[i].Domain = v.As(ns, "domain")
|
||||
ch.Categories[i].Text = v.Value
|
||||
ch.Categories[i].Text = v.GetValue()
|
||||
}
|
||||
|
||||
if n = node.SelectNode(ns, "generator"); n != nil {
|
||||
ch.Generator = Generator{}
|
||||
ch.Generator.Text = n.Value
|
||||
ch.Generator.Text = n.GetValue()
|
||||
}
|
||||
|
||||
ch.TTL = node.I(ns, "ttl")
|
||||
|
@ -83,7 +83,7 @@ func (this *Feed) readRss2(doc *xmlx.Document) (err error) {
|
|||
list = node.SelectNodes(ns, "days")
|
||||
ch.SkipDays = make([]int, len(list))
|
||||
for i, v := range list {
|
||||
ch.SkipDays[i] = days[v.Value]
|
||||
ch.SkipDays[i] = days[v.GetValue()]
|
||||
}
|
||||
|
||||
if n = node.SelectNode(ns, "image"); n != nil {
|
||||
|
@ -126,16 +126,16 @@ func (this *Feed) readRss2(doc *xmlx.Document) (err error) {
|
|||
tl = item.SelectNodes(ns, "link")
|
||||
for _, v := range tl {
|
||||
lnk := new(Link)
|
||||
lnk.Href = v.Value
|
||||
lnk.Href = v.GetValue()
|
||||
i.Links = append(i.Links, lnk)
|
||||
}
|
||||
|
||||
if n = item.SelectNode(ns, "author"); n != nil {
|
||||
i.Author = Author{}
|
||||
i.Author.Name = n.Value
|
||||
i.Author.Name = n.GetValue()
|
||||
}
|
||||
if n = item.SelectNode(ns, "creator"); n != nil {
|
||||
i.Author = Author{ Name: n.Value }
|
||||
i.Author = Author{ Name: n.GetValue() }
|
||||
}
|
||||
|
||||
i.Comments = item.S(ns, "comments")
|
||||
|
@ -146,7 +146,7 @@ func (this *Feed) readRss2(doc *xmlx.Document) (err error) {
|
|||
for _, lv := range tl {
|
||||
cat := new(Category)
|
||||
cat.Domain = lv.As(ns, "domain")
|
||||
cat.Text = lv.Value
|
||||
cat.Text = lv.GetValue()
|
||||
i.Categories = append(i.Categories, cat)
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ func (this *Feed) readRss2(doc *xmlx.Document) (err error) {
|
|||
if src := item.SelectNode(ns, "source"); src != nil {
|
||||
i.Source = new(Source)
|
||||
i.Source.Url = src.As(ns, "url")
|
||||
i.Source.Text = src.Value
|
||||
i.Source.Text = src.GetValue()
|
||||
}
|
||||
|
||||
tl = item.SelectNodes("http://purl.org/rss/1.0/modules/content/", "*")
|
||||
|
|
Loading…
Reference in New Issue