Git Product home page Git Product logo

juju's Introduction

DESCRIPTION

Juju: A nice Objective-C wrapper on the XPathQuery library for parsing HTML with additional nodes extended from Hpple.

AUTHOR

Saravudh Sinsomros

FEATURES

  • Easy searching by XPath (CSS selectors are planned)
  • Parses HTML (XML coming soon)
  • Easy access to tag content, name, and attributes.
  • Easy access to child node.

INSTALLATION

  • Open your XCode project.
  • Drag the "Juju.xcodeproj" file to your project.
  • Add the libxml2.2.dylib framework to your project and search paths as described at Cocoa with Love

USAGE


#import "SSJuju.h"
#import "SSNode.h"

NSString *htmlstr = @"<html><a class='awesome'><b id='1'>One</b><b id='2'>Two</b></a></html>";
NSData *htmlData = [htmlstr dataUsingEncoding:NSASCIIStringEncoding];
SSJuju *doc = [[[SSJuju alloc] initWithHTMLData:htmlData] autorelease];
NSArray *elements = [doc search:@"//a[@class='awesome']"];
for (SSNode *e in elements) {
	SSINode *bNode = [e firstChild];								// Node "b"
	do {
		NSString *idValue = [bNode attributeByName:@"id"]; 			// Easy access to attribute
		NSString *nodeName = [bNode name];							//tag name
		NSString *nodeValue = [[bNode firstChild] description];
		NSLog(@"%@ : %@ : %@",idValue,nodeName,nodeValue);
	} while ((bNode = bNode.right));								// Access to sibling node
}

Result

1 : b : One

2 : b : Two

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.