fixed same extentions space on root level
This commit is contained in:
		
							parent
							
								
									c06dd6d193
								
							
						
					
					
						commit
						7daa266b18
					
				
					 3 changed files with 5 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -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]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								item.go
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								rss.go
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								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
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue