/NDHpple

NDHpple is a Swift wrapper on the XMLPathQuery library.

Primary LanguageSwiftMIT LicenseMIT

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

  • Drag the NDHpple files to your project
  • add the following lines to your project's Bridging Header:
#import <libxml/tree.h>
#import <libxml/parser.h>
#import <libxml/HTMLparser.h>
#import <libxml/xpath.h>
#import <libxml/xpathInternals.h>

USAGE

See AppDelegate.swift for a more detailed sample.

let html = NSString(data: data, encoding: NSUTF8StringEncoding)
let parser = NDHpple(HTMLData: html)
let result = parser.searchWithXPathQuery(query)!

for node in result {
                
    println(node)
}

TODO

  • fix hacky code with further Swift versions
  • more error catching