View Source Gluttony (gluttony v0.3.0)

Parses RSS 2.0 and Atom 1.0 feeds.

References

Extra information

Summary

Functions

Fetches the given url and parses the response. See parse_string/2 for more information on the result values.

Parses a stream of input and returns the values.

Parses the given string and returns the values.

Functions

Link to this function

fetch_feed(url, opts \\ [])

View Source

Fetches the given url and parses the response. See parse_string/2 for more information on the result values.

Link to this function

parse_stream(stream, opts \\ [])

View Source

Parses a stream of input and returns the values.

Examples

Parsing an XML stream from an RSS feed:

stream = File.stream!("rss_feed.xml", :line, [encoding: :utf8])
{:ok, %{feed: feed, entries: entries}} = Gluttony.parse_stream(stream)
Link to this function

parse_string(xml, opts \\ [])

View Source

Parses the given string and returns the values.

Examples

Parsing a xml string from a RSS feed:

{:ok, %{feed: feed, entries: entries}} = Gluttony.parse_string(xml)

When a error happens, the reason is returned:

{:error, reason} = Gluttony.parse_string(xml)

You can retrieve a common result interface by specifing the raw option as false. This might be usefull to retrieve only relevant and common information, since RSS 2.0 and Atom 1.0 are very different specs:

{:ok, %Gluttony.Feed{}} = Gluttony.parse_string(xml, raw: false)