NDHpple is a Swift wrapper on the XMLPathQuery library.
Switch branches/tags
Nothing to show
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Sources changed internals of NDHppleElement and improved code readability Oct 1, 2016
LICENSE.txt Create LICENSE.txt Jun 24, 2014
Package.swift updated for Swift 3 compatibility Sep 22, 2016
README.md updated readme / usage example Oct 1, 2016

README.md

DESCRIPTION

NDHpple is a Swift wrapper on the XMLPathQuery library based on Hpple.

CREDITS

NDHpple was created by Nicolai Davidsson, based on Hpple by Geoffrey Grosenbach, Topfunky Corporation.

INSTALLATION

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.

USAGE

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.