Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterExtensionModule ¶
RegisterExtensionModule registers Module with the specified XML namespace.
Types ¶
type Atom ¶
type Atom struct{}
Atom is an Atom feed parser. https://validator.w3.org/feed/docs/rfc4287.html
Example ¶
The following example is parse an Atom feed.
f, err := os.Open("./a.atom") if err != nil { panic(err) } feed, err := ParseAtom(f) if err != nil { panic(err) } fmt.Println(feed.Title) fmt.Println(feed.Version)
Output:
type ElementExtension ¶
type ElementExtension struct {
Name, Namespace, Value string
}
ElementExtension is an syndication element extension.
type Feed ¶
type Feed struct { Authors []*Person BaseURL string Categories []string Contributors []*Person Copyright string Namespace map[string]string // map[namespace-prefix]namespace-url Description string Generator string Id string ImageURL string Items []*Item Language string // LastUpdatedTime is the feed was last updated time. LastUpdatedTime time.Time Title string Links []*Link Version string ElementExtensions []*ElementExtension }
Feed is top-level feed object, <feed> in Atom 1.0 and <rss> in RSS 2.0.
func Parse ¶
Parse parses a syndication feed(RSS,Atom).
Example ¶
s := `<?xml version="1.0" encoding="UTF-8" ?> <rss version="2.0"> <channel> <title>RSS Title</title> <description>This is an example of an RSS feed</description> <link>http://www.example.com/main.html</link> <lastBuildDate>Mon, 06 Sep 2010 00:01:00 +0000 </lastBuildDate> <pubDate>Sun, 06 Sep 2009 16:20:00 +0000</pubDate> <ttl>1800</ttl> <item> <title>Example entry</title> <description>Here is some text containing an interesting description.</description> <link>http://www.example.com/blog/post/1</link> <guid isPermaLink="false">7bd204c6-1655-4c27-aeee-53f933c5395f</guid> <pubDate>Sun, 06 Sep 2009 16:20:00 +0000</pubDate> </item> </channel> </rss>` feed, err := Parse(strings.NewReader(s)) if err != nil { panic(err) } fmt.Println(feed.Title) fmt.Println(feed.Version) fmt.Println(len(feed.Items))
Output:
type Item ¶
type Item struct { BaseURL string Authors []*Person Contributors []*Person Categories []string Content string Copyright string Id string // LastUpdatedTime is the feed item last updated time. LastUpdatedTime time.Time Links []*Link // PublishDate is the feed item publish date. PublishDate time.Time Summary string Title string ElementExtensions []*ElementExtension }
Item is a feed item.
type Module ¶
Module is an interface is used to handle an extension element which not specified in either the Atom 1.0 or RSS 2.0 specifications.
type ModuleHandlerFunc ¶
ModuleHandlerFunc is a utility function that wrapper a function as Module object.
func (ModuleHandlerFunc) ParseElement ¶
func (f ModuleHandlerFunc) ParseElement(n *xmlquery.Node, v interface{})
type RSS ¶
type RSS struct{}
RSS is an RSS feed parser. https://validator.w3.org/feed/docs/rss2.html
Example ¶
The following example is parse an RSS feed.
f, err := os.Open("./a.rss") if err != nil { panic(err) } feed, err := ParseRSS(f) if err != nil { panic(err) } fmt.Println(feed.Title) fmt.Println(feed.Version)
Output: