diff --git a/feed_test.go b/feed_test.go index f90d5ee..dc84b76 100644 --- a/feed_test.go +++ b/feed_test.go @@ -81,7 +81,7 @@ func Test_Extensions(t *testing.T) { feed := New(1, true, chanHandler, itemHandler) feed.FetchBytes("http://example.com", content, nil) - extension := feed.Channels[0].Items[0].Extensions["http://www.sec.gov/Archives/edgar"] + extension := feed.Channels[0].Items[0].Extensions["http://www.sec.gov/Archives/edgar"][0] companyExpected := "Cellular Biomedicine Group, Inc." companyName := *extension.Childrens[0] diff --git a/item.go b/item.go index 1a301e8..a9b274f 100644 --- a/item.go +++ b/item.go @@ -24,7 +24,7 @@ type Item struct { Contributors []string Content *Content - Extensions map[string]*Extension + Extensions map[string][]*Extension } func (i *Item) Key() string { diff --git a/rss.go b/rss.go index 6855b3f..34e1eee 100644 --- a/rss.go +++ b/rss.go @@ -182,11 +182,11 @@ func (this *Feed) readRss2(doc *xmlx.Document) (err error) { } tl = item.SelectNodes("*", "*") - i.Extensions = make(map[string]*Extension) + i.Extensions = make(map[string][]*Extension) for _, lv := range tl { e, ok := getExtension(lv) if ok { - i.Extensions[lv.Name.Space] = e + i.Extensions[lv.Name.Space] = append(i.Extensions[lv.Name.Space], e) } } @@ -202,6 +202,7 @@ func getExtension(node *xmlx.Node) (*Extension, bool) { var extension Extension extension = Extension{Name: node.Name.Local, Value: node.GetValue()} extension.Attrs = make(map[string]string) + for _, x := range node.Attributes { extension.Attrs[x.Name.Local] = x.Value }