mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-10 17:02:54 +01:00
Continue progress on AtomParser.
This commit is contained in:
parent
88b315554c
commit
ea495d1fe3
@ -21,11 +21,21 @@ final class AtomParser {
|
||||
}
|
||||
|
||||
private let feed: RSSFeed
|
||||
|
||||
private var articles = [RSSArticle]()
|
||||
private var currentArticle: RSSArticle? {
|
||||
articles.last
|
||||
}
|
||||
|
||||
private var attributesStack = [SAXParser.XMLAttributesDictionary]()
|
||||
private var currentAttributes: SAXParser.XMLAttributesDictionary? {
|
||||
attributesStack.last
|
||||
}
|
||||
|
||||
private var parsingArticle = false
|
||||
private var parsingXHTML = false
|
||||
private var endFeedFound = false
|
||||
|
||||
static func parsedFeed(with parserData: ParserData) -> RSSFeed {
|
||||
|
||||
let parser = AtomParser(parserData)
|
||||
@ -48,6 +58,11 @@ private extension AtomParser {
|
||||
feed.articles = articles
|
||||
}
|
||||
|
||||
func addArticle() {
|
||||
let article = RSSArticle(feedURL)
|
||||
articles.append(article)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -55,6 +70,24 @@ extension AtomParser: SAXParserDelegate {
|
||||
|
||||
public func saxParser(_ saxParser: SAXParser, xmlStartElement localName: XMLPointer, prefix: XMLPointer?, uri: XMLPointer?, namespaceCount: Int, namespaces: UnsafePointer<XMLPointer?>?, attributeCount: Int, attributesDefaultedCount: Int, attributes: UnsafePointer<XMLPointer?>?) {
|
||||
|
||||
if endFeedFound {
|
||||
return
|
||||
}
|
||||
|
||||
let xmlAttributes = saxParser.attributesDictionary(attributes, attributeCount: attributeCount) ?? SAXParser.XMLAttributesDictionary()
|
||||
attributesStack.append(xmlAttributes)
|
||||
|
||||
if parsingXHTML {
|
||||
// addXHTMLTag(localName)
|
||||
return
|
||||
}
|
||||
|
||||
// if SAXEqualTags(localName, "entry") {
|
||||
// parsingArticle = true
|
||||
// addArticle()
|
||||
// return
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
public func saxParser(_ saxParser: SAXParser, xmlEndElement localName: XMLPointer, prefix: XMLPointer?, uri: XMLPointer?) {
|
||||
|
Loading…
Reference in New Issue
Block a user