views:

302

answers:

1

I am new to iphone development.I want to parse and retrieve a particular content from the HTML file at the url.I have a sample code from this link http://blog.objectgraph.com/index.php/2010/02/24/parsing-html-iphone-development/

 NSData *htmlData = [[NSString stringWithContentsOfURL:[NSURL URLWithString: @"http://www.objectgraph.com/contact.html"]] dataUsingEncoding:NSUTF8StringEncoding];
 TFHpple *xpathParser = [[TFHpple alloc] initWithHTMLData:htmlData];  
 NSArray *elements  = [xpathParser search:@"//h3"]; // get the page title
 TFHppleElement *element = [elements objectAtIndex:0];
 NSString *h3Tag = [element content];  
 NSLog(h3Tag);
 mLabel.text = h3Tag;

They are retrieving the content in the h3 tag of the source , it displays properly contact us .I have changed the url as stack overflow and searched for title ,it retrieves the title properly.But i am not able to retrieve the content of the attributes of tags.Please help me out.Please guide me.Thanks

A: 

you can use //h3[@attribute='something'] in your query

or

you can use [element attributes] to get all associated with that particular attribute.

Bryan Clark