-
Notifications
You must be signed in to change notification settings - Fork 0
/
opml.go
35 lines (30 loc) · 796 Bytes
/
opml.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import "encoding/xml"
type OPML struct {
XMLName xml.Name `xml:"opml"`
Version string `xml:"version,attr"`
Title string `xml:"head>title"`
Docs string `xml:"head>docs"`
Outlines []Outline `xml:"body>outline"`
}
type Outline struct {
Text string `xml:"text,attr"`
Type string `xml:"type,attr"`
URL string `xml:"xmlUrl,attr"`
Outlines []Outline `xml:"outline"`
}
func _extract(outlines []Outline, feeds *[]string) []string {
for _, outline := range outlines {
switch {
case outline.URL != "":
*feeds = append(*feeds, outline.URL)
case len(outline.Outlines) > 0:
_extract(outline.Outlines, feeds)
}
}
return *feeds
}
func (root OPML) urls() []string {
var feeds []string
return _extract(root.Outlines, &feeds)
}