Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/topfunky/hpple
An XML/HTML parser for Objective-C, inspired by Hpricot.
https://github.com/topfunky/hpple
Last synced: 2 days ago
JSON representation
An XML/HTML parser for Objective-C, inspired by Hpricot.
- Host: GitHub
- URL: https://github.com/topfunky/hpple
- Owner: topfunky
- License: mit
- Created: 2009-02-01T00:00:26.000Z (almost 16 years ago)
- Default Branch: master
- Last Pushed: 2021-07-15T04:18:17.000Z (over 3 years ago)
- Last Synced: 2024-10-29T15:35:05.256Z (3 months ago)
- Language: Objective-C
- Homepage: http://topfunky.com
- Size: 109 KB
- Stars: 2,774
- Watchers: 108
- Forks: 473
- Open Issues: 39
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE.txt
Awesome Lists containing this project
- awesome - hpple - An XML/HTML parser for Objective-C, inspired by Hpricot. (etc)
- awesome - hpple - An XML/HTML parser for Objective-C, inspired by Hpricot. (etc)
README
[![Build Status](https://travis-ci.org/premedios/hpple.png)](https://travis-ci.org/premedios/hpple)
# DESCRIPTION
Hpple: A nice Objective-C wrapper on the XPathQuery library for parsing HTML.
Inspired by why the lucky stiff's [Hpricot](http://github.com/why/hpricot/tree/master).
# CREDITS
Hpple was created by Geoffrey Grosenbach, [Topfunky Corporation](http://topfunky.com) and [PeepCode Screencasts](http://peepcode.com).
[Contributors](https://github.com/topfunky/hpple/graphs/contributors)
# FEATURES
* Easy searching by XPath (CSS selectors are planned)
* Parses HTML (XML coming soon)
* Easy access to tag content, name, and attributes.# INSTALLATION
* Open your Xcode project and the Hpple project.
* Drag the "Hpple" directory to your project.
* Add the libxml2.2.dylib framework to your project and search paths as described at [Cocoa with Love](http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html)More documentation and short screencast coming soon...
# USAGE
See TFHppleHTMLTest.m in the Hpple project for samples.
```objc
#import "TFHpple.h"NSData * data = [NSData dataWithContentsOfFile:@"index.html"];
TFHpple * doc = [[TFHpple alloc] initWithHTMLData:data];
NSArray * elements = [doc search:@"//a[@class='sponsor']"];TFHppleElement * element = [elements objectAtIndex:0];
[e text]; // The text inside the HTML element (the content of the first text node)
[e tagName]; // "a"
[e attributes]; // NSDictionary of href, class, id, etc.
[e objectForKey:@"href"]; // Easy access to single attribute
[e firstChildWithTagName:@"b"]; // The first "b" child node
```# TODO
* Internal error catching and messages
* CSS3 selectors in addition to XPath