Create a FeedParser
and provide with Data
or an InputStream
, that represents an Atom, JSON, or RSS feed:
let parser = FeedParser(data: data) // or FeedParser(xmlStream: stream)
Then call parse
to start parsing the feed:
let result = parser.parse()
FeedKit returns a Result<Feed, ParserError>
, and as such, if parsing succeeds you should now have a strongly-typed model of an RSS
, Atom
or JSON Feed
, within the Feed
enum:
switch result {
case .success(let feed):
// Get the parsed feed directly as an optional Atom, JSON, or RSS feed object
feed.atomFeed
feed.jsonFeed
feed.rssFeed
// Or alternatively...
switch feed {
case let .atom(feed): // Atom Syndication Format Feed Model
case let .json(feed): // JSON Feed Model
case let .rss(feed): // Really Simple Syndication Feed Model
}
case .failure(let error):
print(error)
}
- From the File menu, select Add Packages…
- Enter "https://github.com/sebj/FeedKit" into the package repository URL text field
Add the following to the dependencies
of your Package.swift
file:
.package(url: "https://github.com/sebj/FeedKit.git", ...)
This library is released under the MIT license. See LICENSE for details.