NDHpple is a Swift wrapper on the XMLPathQuery library based on Hpple.
NDHpple was created by Nicolai Davidsson, based on Hpple by Geoffrey Grosenbach, Topfunky Corporation.
Build the package with the most recent Swift 2.2 Snapshot (as of January 28th) with this command:
swift build -Xcc -I/usr/include/libxml2 -c release
This will build NDHpple as module. You can also pass this URL (http://github.com/ndavon/NDHpple) as dependency in another package but you'll still have to pass the include path as compiler flag.
See Example/main.swift for a more detailed sample.
import NDHpple let html = try! String(contentsOf: URL(string: url)!) let parser = NDHpple(HTMLData: html) let result = parser.search(withQuery: query) result.flatMap { $0.text }.forEach { print($0) }
Please note that some slight modifications were made that will probably break your existing implementation.