Skip to content

youngsing/OCGumbo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OCGumbo - An Objective-C HTML5 parser.

OCGumbo is an Objective-C wrapper of the Google Gumbo.

Basic Usage

  1. Add Gumbo sources or lib to your project.
  2. Add OCGumbo file and import "OCGumbo.h", then use OCGumboDocument to parse an html string.
OCGumboDocument *document = [[OCGumboDocument alloc] initWithHTMLString:htmlString];
OCGumboElement *root = document.rootElement;
//document: do something with the document.
//rootElement: do something with the html tree.

Extension

Now, OCGumbo add more Query support, add "OCGumbo+Query.h" and enjoy it.

####Query APIs####

.Query();
.attr();
.text();
.find();
.children();
.parent();
.parents();
.first();
.last();
.get();
.index();
.hasClass();

####Examples:####

NSLog(@"options: %@", document.Query(@"body").find(@"#select").find(@"option"));
        
NSLog(@"title: %@", document.Query(@"title").text());
        
NSLog(@"attribute: %@", document.Query(@"select").first().attr(@"id"));

NSLog(@"class: %@", document.Query(@"#select").parents(@".main"));

About

An Objective-C HTML5 parser.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published