Skip to content
This repository

An XML/HTML parser for Objective-C, inspired by Hpricot.

branch: master

Merge pull request #43 from draganjovev/master

Added safeguard for PerformXPathQuery()
latest commit 24ba958e31
Geoffrey Grosenbach authored
Octocat-spinner-32 Classes ARC-ify May 13, 2012
Octocat-spinner-32 Hpple.xcodeproj Added travis December 08, 2013
Octocat-spinner-32 UnitTesting Minor test cleanup for iPhone OS 3.0. Still crashes after tests run. July 27, 2009
Octocat-spinner-32 .gitattributes First import January 31, 2009
Octocat-spinner-32 .gitignore Ignore other Xcode files January 31, 2009
Octocat-spinner-32 .travis.yml Added travis December 08, 2013
Octocat-spinner-32 GTMDefines.h First import January 31, 2009
Octocat-spinner-32 GTMIPhoneUnitTestDelegate.h First import January 31, 2009
Octocat-spinner-32 GTMIPhoneUnitTestDelegate.m First import January 31, 2009
Octocat-spinner-32 GTMIPhoneUnitTestMain.m First import January 31, 2009
Octocat-spinner-32 GTMSenTestCase.h First import January 31, 2009
Octocat-spinner-32 GTMSenTestCase.m First import January 31, 2009
Octocat-spinner-32 Hpple.podspec Add podspec file April 10, 2014
Octocat-spinner-32 Hpple_Prefix.pch First import January 31, 2009
Octocat-spinner-32 Info.plist First import January 31, 2009
Octocat-spinner-32 LICENSE.txt First import January 31, 2009
Octocat-spinner-32 MainWindow.xib First import January 31, 2009
Octocat-spinner-32 README.markdown Update README.markdown December 08, 2013
Octocat-spinner-32 TFHpple.h Merging latest changes from upstream. May 16, 2013
Octocat-spinner-32 TFHpple.m Added support for element xpath query September 12, 2013
Octocat-spinner-32 TFHppleElement.h Removed NSCopying and NSString cast from objectForKeyedSubscript: December 04, 2013
Octocat-spinner-32 TFHppleElement.m Removed NSCopying and NSString cast from objectForKeyedSubscript: December 04, 2013
Octocat-spinner-32 Test-Info.plist First import January 31, 2009
Octocat-spinner-32 XPathQuery.h Added support for data encoding May 06, 2013
Octocat-spinner-32 XPathQuery.m Added safeguard for PerformXPathQuery() March 10, 2014
Octocat-spinner-32 main.m ARC-ify May 13, 2012
README.markdown

Build Status

DESCRIPTION

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

Inspired by why the lucky stiff's Hpricot.

CREDITS

Hpple was created by Geoffrey Grosenbach, Topfunky Corporation and PeepCode Screencasts.

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

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 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
Something went wrong with that request. Please try again.