public
Description: An XML/HTML parser for Objective-C, inspired by Hpricot.
Homepage: http://topfunky.com
Clone URL: git://github.com/topfunky/hpple.git
hpple /
name age message
file .gitattributes Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
file .gitignore Sat Jan 31 15:53:47 -0800 2009 Ignore other Xcode files [topfunky]
directory Classes/ Mon Jul 27 12:28:18 -0700 2009 Minor test cleanup for iPhone OS 3.0. Still cra... [topfunky]
file GTMDefines.h Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
file GTMIPhoneUnitTestDelegate.h Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
file GTMIPhoneUnitTestDelegate.m Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
file GTMIPhoneUnitTestMain.m Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
file GTMSenTestCase.h Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
file GTMSenTestCase.m Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
directory Hpple.xcodeproj/ Mon Jul 27 12:28:18 -0700 2009 Minor test cleanup for iPhone OS 3.0. Still cra... [topfunky]
file Hpple_Prefix.pch Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
file Info.plist Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
file LICENSE.txt Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
file MainWindow.xib Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
file README.markdown Sat Jan 31 16:07:59 -0800 2009 Corrected usage sample in README, again [topfunky]
file TFHpple.h Fri Feb 27 22:18:45 -0800 2009 Added XML Parsing. [topfunky]
file TFHpple.m Mon Jul 27 12:28:18 -0700 2009 Minor test cleanup for iPhone OS 3.0. Still cra... [topfunky]
file TFHppleElement.h Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
file TFHppleElement.m Mon Jul 27 12:28:18 -0700 2009 Minor test cleanup for iPhone OS 3.0. Still cra... [topfunky]
file Test-Info.plist Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
directory UnitTesting/ Mon Jul 27 12:28:18 -0700 2009 Minor test cleanup for iPhone OS 3.0. Still cra... [topfunky]
file XPathQuery.h Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
file XPathQuery.m Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
file main.m Sat Jan 31 15:52:47 -0800 2009 First import [topfunky]
README.markdown

DESCRIPTION

EXPERIMENTAL! Only a few hours old.

Hpple: A nice Objective-C wrapper on the XPathQuery library for parsing HTML.

Inspired by why the lucky stiff's Hpricot.

AUTHOR

Geoffrey Grosenbach, Topfunky Corporation and PeepCode Screencasts.

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

More documentation and short screencast coming soon...

USAGE

See TFHppleHTMLTest.m in the Hpple project for samples.

#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 content];              // Tag's innerHTML
[e tagName];              // "a"
[e attributes];           // NSDictionary of href, class, id, etc.
[e objectForKey:@"href"]; // Easy access to single attribute

TODO

  • Internal error catching and messages
  • CSS3 selectors in addition to XPath