Example #1
0
// Parses a feed from string contents
func (this *Feed) Parse(feed string, charset xmlx.CharsetFunc) (err error) {
	this.Document = xmlx.New()
	if err = this.Document.LoadString(feed, charset); err != nil {
		return
	}
	return this.makeFeed()
}
Example #2
0
func (this *Feed) FetchBytes(uri string, content []byte, charset xmlx.CharsetFunc) (err error) {
	this.Url = uri

	this.Document = xmlx.New()

	if err = this.Document.LoadBytes(content, charset); err != nil {
		return
	}

	return this.makeFeed()
}
Example #3
0
// Fetch retrieves the feed's latest content if necessary.
//
// The charset parameter overrides the xml decoder's CharsetReader.
// This allows us to specify a custom character encoding conversion
// routine when dealing with non-utf8 input. Supply 'nil' to use the
// default from Go's xml package.
//
// The client parameter allows the use of arbitrary network connections, for
// example the Google App Engine "URL Fetch" service.
func (this *Feed) FetchClient(uri string, client *http.Client, charset xmlx.CharsetFunc) (err error) {
	if !this.CanUpdate() {
		return
	}

	this.Url = uri
	this.Document = xmlx.New()

	if err = this.Document.LoadUriClient(uri, client, charset); err != nil {
		return
	}

	return this.makeFeed()
}