Swiftpack.co - pixel-foundry/opml as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by pixel-foundry.
pixel-foundry/opml 0.0.5
OPML parser and generator for Swift projects
⭐️ 14
🕓 38 weeks ago
.package(url: "https://github.com/pixel-foundry/opml.git", from: "0.0.5")

OPML

OPML is a Swift package for parsing and creating OPML files.

This package aims to create an opinionated, but strongly-typed and correct implementation of the OPML spec. For instance, the OPML spec defines some rarely-used properties related to the internal state of a hypothetical desktop application, like vertScrollState and windowTop, which this implementation deems unnecessary and omits.

Usage

Parsing OPML files

You can use OPML with either a file URL or data:

import OPML

let parser = try OPMLParser(file: fileURL)
let opml = try parser.parse() // OPML(version: "2.0", title: Optional("Feedly"), ...

// or, with data you’ve downloaded:

let parser = try OPMLParser(data)
let opml = try parser.parse() // OPML(version: "2.0", title: Optional("Feedly"), ...

Creating and exporting OPML files

Create an OPML model from a list of RSS feed entries (or anything else, really).

OPML provides the xml property and xml(indented: Bool) function to export a string containing your rendered OPML XML.

import OPML

let rssFeeds = [...] // your RSS feed models

let opml = OPML(title: "RSS Feeds", entries: rssFeeds.map { feed -> OPMLEntry in
    OPMLEntry(rss: feed.url, title: feed.title)
})
let xml = opml.xml
// <?xml version="1.0" encoding="UTF-8"?><opml version="2.0"><head><title>RSS Feeds...

Installation

SwiftPM:

dependencies: [
    .package(name: "OPML", url: "https://github.com/pixel-foundry/opml", from: "0.0.1")
],
targets: [
    .target(name: "YourTarget", dependencies: ["OPML"])
]

GitHub

link
Stars: 14
Last commit: 38 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Dependencies

Related Packages

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics