Useful Extension to combine Alamofire and SwiftyXMLParser
- iOS 9.0+
- Swift 3.0+
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Alamofire_XMLParser', :git => 'https://github.com/tin612/Alamofire_XMLParser.git'
> pod install
import Alamofire
import SwiftyXMLParser
import Alamofire_XMLParser
Alamofire.request("http://laodong.com.vn/rss/home.rss").responseXML(completionHandler: {
response in
switch response.result {
case .success(let xml):
var root = xml["rss","channel", "item"]
var xmlRoot = xml["rss","channel", "item"].all
var dateKey = "pubDate"
for element in root {
let title = element["title"].text
let link = element["link"].text
print(link)
}
case .failure(let error):
print(error.localizedDescription)
}
})
import Alamofire
import SwiftyXMLParser
import Alamofire_XMLParser
Alamofire.request("http://laodong.com.vn/rss/home.rss").responseXML(completionHandler: {
response in
switch response.result {
case .success(let xml):
var root = xml["rss","channel", "item"]
var xmlRoot = xml["rss","channel", "item"].all
var dateKey = "pubDate"
for element in root {
let title = element["title"].text
let link = element["link"].text
}
case .failure(let error):
print(error.localizedDescription)
}
})
Alamofire callbacks a parsed value with SwiftyXMLParser.
#Version 1.2 Update
var keyElement: String = "description" // "content"
let content = element[keyElement].text?.stringByDecodingHTMLEscapeCharacters().getImageURLsFromContent()
Copyright (c) 2017 Tin Phan This reposities is Swift 3.0 version of https://github.com/kazuhiro4949/Alamofire-SwiftyXMLParser.