hpple

NSString with some html tags, how can I search for <img> tag and get the content of url

半世苍凉 提交于 2019-12-30 01:25:27
问题 I have a NSString with some html tags, how can I search for tag and get the content of url? I'm not sure if I must use Hpple or a simple Regex expression. In both cases can I have some example? 回答1: One way to do this is using NSScanner. See this example: NSString *url = nil; NSString *htmlString = ... NSScanner *theScanner = [NSScanner scannerWithString:htmlString]; // find start of IMG tag [theScanner scanUpToString:@"<img" intoString:nil]; if (![theScanner isAtEnd]) { [theScanner

Unable to get data from a div tag using HTML parsing (hpple) in iPhone

为君一笑 提交于 2019-12-25 08:17:20
问题 I am trying to parse the below link using hpple: http://www.decanter.com/news/wine-news/529748/mimimum-pricing-opponents-slam-cameron-speech Code: - (void)parseURL:(NSURL *)url { NSData *htmlData = [NSData dataWithContentsOfURL:url]; TFHpple *xpathParser = [[TFHpple alloc] initWithHTMLData:htmlData]; NSArray *elements = [xpathParser searchWithXPathQuery:@"<div class=\"body\" id=\"article-529748-body\">"]; NSLog(@"elements %@",elements); TFHppleElement *element = [elements objectAtIndex:0];

iOS Parse HTML attribute with Hpple

折月煮酒 提交于 2019-12-12 05:37:16
问题 I am trying to retrieve an attribute in an input tag in HTML. My NSLog is coming back null. What's wrong with my syntax? I am trying to retrieve the value for "value=" in the input tag. Heres the HTML I am parsing: <input name="hidXMLID" type="hidden" id="hidXMLID" value="0311sg55dbmnk0nsuzoflnij" /> Heres the parser syntax: NSURL *theURL = [NSURL URLWithString:@"http://www.wccca.com/PITS/"]; NSData *data = [[NSData alloc] initWithContentsOfURL:theURL]; xpathParser = [[TFHpple alloc]

How do I get the nth element with a certain name in the entire XML document?

允我心安 提交于 2019-12-11 18:39:47
问题 so will something like this work using Hpple Xpath //a[4] The fourth tag in a html tree? Or do i need to do it programmatically by counting in a for() loop? 回答1: The XPath for the fourth <a> in an HTML document is: (//a)[4] Your example //a[4] will produce a set of all <a> s that are the fourth <a> in their respective parent, and that is not what you want here. See also: https://stackoverflow.com/a/14209492/1945651 来源: https://stackoverflow.com/questions/15664001/how-do-i-get-the-nth-element

hpple XPath query for complex html

萝らか妹 提交于 2019-12-11 17:15:03
问题 I have a complex html file that I need to parse in Objective-C. The html looks like <HTML> <TABLE width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="10" align="left" valign="top"><img src="http://www.indianrail.gov.in/main_text_left_top2.gif" alt="" width="8" height="8"></td> <td width="100%" align="left" valign="top" class="text_rail_top"><img src="http://www.indianrail.gov.in/blank.gif" alt="" width="1" height="8"></td> <td width="10" align="right" valign="top"><img

TFHppleElement (Hpple), parsing HTML on iphone

我的梦境 提交于 2019-12-10 11:15:39
问题 I'm using Hpple and it's been great so far however I want to get all the divs inside another and that I can do. But then I am unable to further parse the contents (innerHTML, and in the source it is labelled innerHTML not innerText) asking for the elements content returns nothing as there is no text directly in that element, only child nodes/elements which then contain text. What alternatives are there to Hpple and parsing HTML on the iPhone. 回答1: The alternatives to Hpple I have found so far

Hpple parsing HTML with Objective-C

只愿长相守 提交于 2019-12-10 10:45:14
问题 I've follow the tutorial from RayWendErlich to parse HTML node. I get the content from an index.html . I've try to use this method to fetch the background value. + (void)parseWithHTMLString:(NSString *)string { NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding]; TFHpple *parser = [TFHpple hppleWithData:data isXML:NO]; NSString *XpathQueryString = @"//div[class='content']/div/div"; NSArray *nodes = [parser searchWithXPathQuery:XpathQueryString]; NSLog(@"%@",nodes); NSMutableArray

Hpple parsing HTML with Objective-C

邮差的信 提交于 2019-12-06 11:49:11
I've follow the tutorial from RayWendErlich to parse HTML node. I get the content from an index.html . I've try to use this method to fetch the background value. + (void)parseWithHTMLString:(NSString *)string { NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding]; TFHpple *parser = [TFHpple hppleWithData:data isXML:NO]; NSString *XpathQueryString = @"//div[class='content']/div/div"; NSArray *nodes = [parser searchWithXPathQuery:XpathQueryString]; NSLog(@"%@",nodes); NSMutableArray *resultArray = [[NSMutableArray alloc] initWithCapacity:0]; for (TFHppleElement *element in nodes) {

TFHppleElement (Hpple), parsing HTML on iphone

前提是你 提交于 2019-12-06 10:50:00
I'm using Hpple and it's been great so far however I want to get all the divs inside another and that I can do. But then I am unable to further parse the contents (innerHTML, and in the source it is labelled innerHTML not innerText) asking for the elements content returns nothing as there is no text directly in that element, only child nodes/elements which then contain text. What alternatives are there to Hpple and parsing HTML on the iPhone. The alternatives to Hpple I have found so far were: ElementParser Objective-C HTML Parser XPathQuery Since I am in the process of researching the issue

NSString with some html tags, how can I search for <img> tag and get the content of url

混江龙づ霸主 提交于 2019-11-30 05:43:32
I have a NSString with some html tags, how can I search for tag and get the content of url? I'm not sure if I must use Hpple or a simple Regex expression. In both cases can I have some example? One way to do this is using NSScanner . See this example: NSString *url = nil; NSString *htmlString = ... NSScanner *theScanner = [NSScanner scannerWithString:htmlString]; // find start of IMG tag [theScanner scanUpToString:@"<img" intoString:nil]; if (![theScanner isAtEnd]) { [theScanner scanUpToString:@"src" intoString:nil]; NSCharacterSet *charset = [NSCharacterSet characterSetWithCharactersInString: