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.
- 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>
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) }
- fix hacky code with further Swift versions
- more error catching