-
Notifications
You must be signed in to change notification settings - Fork 28
/
opml.go
42 lines (34 loc) · 806 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
36
37
38
39
40
41
42
package mylib
import (
"io/ioutil"
"encoding/xml"
)
type Opml struct {
XMLName xml.Name `xml:"opml"`
Version string `xml:"version,attr"`
Head OpmlHead
Body OpmlBody
}
type OpmlHead struct {
XMLName xml.Name `xml:"head"`
Title string `xml:"title"`
}
type OpmlBody struct {
XMLName xml.Name `xml:"body"`
SiteList []OpmlOutline `xml:"outline"`
}
type OpmlOutline struct {
Text string `xml:"text,attr"`
Title string `xml:"title,attr"`
Type string `xml:"type,attr"`
XmlUrl string `xml:"xmlUrl,attr"`
HtmlUrl string `xml:"htmlUrl,attr"`
Favicon string `xml:"rssfr-favicon,attr"`
}
func GetOutlineList(filepath string) []OpmlOutline {
v := Opml{}
content, _ := ioutil.ReadFile(filepath)
err := xml.Unmarshal(content, &v)
if err != nil { panic(err) }
return v.Body.SiteList
}