38 lines
569 B
Go
38 lines
569 B
Go
package opml
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"os"
|
|
)
|
|
|
|
type Outline struct {
|
|
Outlines []Outline `xml:"outline"`
|
|
Text string `xml:"text,attr"`
|
|
Title string `xml:"title,attr"`
|
|
Type string `xml:"type,attr"`
|
|
XmlUrl string `xml:"xmlUrl,attr"`
|
|
}
|
|
|
|
type Body struct {
|
|
Outline []Outline `xml:"body>outline"`
|
|
}
|
|
|
|
type OPML struct {
|
|
XMLName xml.Name `xml:"opml"`
|
|
Body `xml:"opml>body"`
|
|
}
|
|
|
|
func Unmarshal(path string) OPML {
|
|
data, err := os.ReadFile(path)
|
|
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
opml := OPML{}
|
|
|
|
xml.Unmarshal(data, &opml)
|
|
|
|
return opml
|
|
}
|