Skip to content
/ hpple Public
forked from topfunky/hpple

An HTML/XML Parser which allows navigation through the hierachy via dot-notation

License

Notifications You must be signed in to change notification settings

feigi/hpple

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DESCRIPTION

EXPERIMENTAL! I am not entirely sure whether it is fully XML compliant.

This is a customized version of topfunky's Hpple.

AUTHOR

Geoffrey Grosenbach, Christian Ziegler, Topfunky Corporation and PeepCode Screencasts.

FEATURES

  • Easy searching by XPath
  • Parses HTML and XML
  • Easy access to tag content, name, and attributes via dot-notation

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

For usage only the following classes are needed:

  • TFHpple.m/.h
  • TFHppleElement.m/.h
  • XPathQuery.m/.h

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;              // The text surounded by the tag
e.name;              	// "a"
e.attributes;           // NSDictionary containing TFHppleElements for the attributes
e.childNodes;		// NSDictionary containing TFHppleElements for the childNodes

// If you need the value of the href attribute you access it like this
NSString * value = [e valueForKeyPath:@"attributes.href.content"];

About

An HTML/XML Parser which allows navigation through the hierachy via dot-notation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 64.9%
  • Objective-C 34.1%
  • Shell 1.0%