Fiet v0.2.2 Fiet.Atom View Source

Atom parser, comply with RFC 4287.

Text constructs

Fiet supports two out of three text contructs in Atom: text and html. xhtml is not supported.

In text constructs fields, the returning format is {format, data}. If “type” attribute does not exist in the tag, format will be text by default.

For example, <title type="html">Less: &lt;em> &amp;lt; &lt;/em></title> will give you {:html, "Less: &lt;em> &amp;lt; &lt;/em>"}.

Person constructs

There are three attributes in Person construct: name, uri and email, both contributors and authors returned by the parser will be in Fiet.Atom.Person struct.

See Fiet.Atom.Person for more information.

Link to this section Summary

Functions

Parses Atom document feed

Link to this section Functions

Parses Atom document feed.

Example

iex> Fiet.Atom.parse(atom)
{:ok,
%Fiet.Atom.Feed{
  authors: [],
  categories: [
   %Fiet.Atom.Category{label: "Space", scheme: nil, term: "space"},
   %Fiet.Atom.Category{label: "Science", scheme: nil, term: "science"}
  ],
  contributors: [],
  entries: [
   %Fiet.Atom.Entry{
     authors: [
       %Fiet.Atom.Person{
         email: "john.doe@example.com",
         name: "John Doe",
         uri: "http://example.org/"
       }
     ],
     categories: [],
     content: {:text, "Test Content"},
     contributors: [
       %Fiet.Atom.Person{email: nil, name: "Joe Gregorio", uri: nil},
       %Fiet.Atom.Person{email: nil, name: "Sam Ruby", uri: nil}
     ],
     id: "tag:example.org,2003:3.2397",
     link: %Fiet.Atom.Link{
       href: "http://example.org/audio/ph34r_my_podcast.mp3",
       href_lang: nil,
       length: "1337",
       rel: "enclosure",
       title: nil,
       type: "audio/mpeg"
     },
     published: nil,
     rights: {:xhtml, :skipped},
     source: nil,
     summary: nil,
     title: {:text, "Atom draft-07 snapshot"},
     updated: "2005-07-31T12:29:29Z"
   }
  ],
  generator: %Fiet.Atom.Generator{
   text: "
   Example Toolkit
 ",
   uri: "http://www.example.com/",
   version: "1.0"
  },
  icon: nil,
  id: "tag:example.org,2003:3",
  link: %Fiet.Atom.Link{
   href: "http://example.org/feed.atom",
   href_lang: nil,
   length: nil,
   rel: "self",
   title: nil,
   type: "application/atom+xml"
  },
  logo: nil,
  rights: {:text, "Copyright (c) 2003, Mark Pilgrim"},
  subtitle: {:html,
  "
   A &lt;em&gt;lot&lt;/em&gt; of effort
   went into making this effortless
 "},
  title: {:text, "dive into mark"},
  updated: "2005-07-31T12:29:29Z"
}}