You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+88-83Lines changed: 88 additions & 83 deletions
Original file line number
Diff line number
Diff line change
@@ -7,13 +7,13 @@ FeedKit is a Swift library for Parsing and Generating RSS, Atom, and JSON feeds.
7
7
8
8
### FeedKit v10 :warning:
9
9
10
-
FeedKit `v10` is currently in **beta**. It should be stable enough :eyes:, but if stable enough is not enough, consider using **[`v9`](https://github.com/nmdias/FeedKit/releases/tag/9.1.2)** for now. The beta version includes a new parsing engine, features and improvements, and may contain bugs that still need to be ironed out and unit tested.
10
+
FeedKit **[`v10`](https://github.com/nmdias/FeedKit)** is currently in **beta**. It should be stable enough :eyes:, but if stable enough is not enough, consider using **[`v9`](https://github.com/nmdias/FeedKit/releases/tag/9.1.2)** for now. The beta version includes a new parsing engine, features and improvements, and may contain bugs that still need to be ironed out and unit tested.
If you don't know the type of feed, use the `Feed` enum.
40
46
41
-
The `Feed` enum allows you to handle various feed formats, including `RSS`, `Atom`, `RDF`, and `JSON` feeds. This makes it a versatile solution for parsing any type of feed.
47
+
The `Feed` enum type allows you to handle various feed formats, including **RSS**, **Atom**and **JSON** feeds. This makes it a versatile solution for parsing any type of feed.
42
48
43
49
```swift
44
-
//Initialize and parse a feed
50
+
//Fetch and parse a feed
45
51
let feed =tryawaitFeed(urlString: "https://example.com/feed")
46
52
47
53
// Use a switch to handle different feeds explicitly
@@ -53,12 +59,57 @@ case let .json(feed): // JSON Feed Model
53
59
}
54
60
55
61
// Or through optional properties
56
-
feed.rssFeed// feed.atomFeed, feed.jsonFeed, ...
62
+
feed.rss// feed.atom, feed.rdf, feed.json, ...
63
+
```
64
+
65
+
### Initializers
66
+
67
+
All feed types provide multiple initializers. They provide a flexible way to fetch and parse feeds from the most common sources.
68
+
69
+
<details>
70
+
<summary>Show</summary>
71
+
72
+
From a URL `String`:
73
+
74
+
```swift
75
+
init(urlString: String) asyncthrows
76
+
```
77
+
78
+
From a `URL`, handling both local file URLs and remote URLs:
79
+
80
+
```swift
81
+
init(url: URL) asyncthrows
82
+
```
83
+
84
+
From a local file `URL`:
85
+
86
+
```swift
87
+
init(fileURLurl: URL) throws
88
+
```
89
+
90
+
From a remote `URL`:
91
+
92
+
```swift
93
+
init(remoteURLurl: URL) asyncthrows
94
+
```
95
+
96
+
From an XML or JSON `String`:
97
+
98
+
```swift
99
+
init(string: String) throws
100
+
```
101
+
102
+
From raw `Data`:
103
+
104
+
```swift
105
+
init(data: Data) throws
57
106
```
58
107
108
+
</details>
109
+
59
110
## Feed Generation
60
111
61
-
To generate XML for a Feed, create an instance of an `RSSFeed`, `AtomFeed`or `JSONFeed` and populate it with the necessary data.
112
+
To generate an XML string for any given XML feed, create an instance of an `RSSFeed`or `AtomFeed` and populate it with the necessary data.
62
113
63
114
```swift
64
115
let feed =RSSFeed(
@@ -106,89 +157,43 @@ let xmlString = try feed.toXMLString(formatted: true)
106
157
107
158
</details>
108
159
109
-
## Initializers
110
-
111
-
All Feed types, `Feed`, `RSSFeed`, `JSON...` provide various initializers for flexibility in loading and parsing feed data.
112
-
113
-
<details>
114
-
<summary>Show</summary>
115
-
116
-
From a URL `String`:
117
-
118
-
```swift
119
-
init(urlString: String) asyncthrows
120
-
```
121
-
122
-
From a `URL`, handling both local file URLs and remote URLs:
123
-
124
-
```swift
125
-
init(url: URL) asyncthrows
126
-
```
127
-
128
-
From a local file `URL`:
129
-
130
-
```swift
131
-
init(fileURLurl: URL) throws
132
-
```
133
-
134
-
From a remote `URL`:
135
-
136
-
```swift
137
-
init(remoteURLurl: URL) asyncthrows
138
-
```
139
-
140
-
From an XML or JSON `String`:
141
-
142
-
```swift
143
-
init(string: String) throws
144
-
```
145
-
146
-
From raw `Data`:
147
-
148
-
```swift
149
-
init(data: Data) throws
150
-
```
151
-
152
-
These initializers provide a flexible way to load feeds from the most common sources.
153
-
154
-
</details>
155
-
156
160
## Feed Models
157
161
158
-
The `RSS`, `Atom`, and `JSON` feed models are highly comprehensive, especially when combined with the supported namespaces. Below is just a small preview of what’s available.
162
+
The **RSS**, **Atom**, and **JSON** feed models are highly comprehensive, especially when combined with all the supported namespaces. Below is a small preview of what’s available.
0 commit comments