iPhone HTML Parsing child elements with XPath

Alergeniikeere

New Member
I'm trying to get the 'title' fields and 'background-color' style out of the element. - I'm so new to objective-c and this is most likly easy...My HTML (sample repeats with different \[code\]<TD class='class name'>\[/code\]:\[code\] </table></TD><TD class="targetmonth calday"><table style="height: 60px;" WIDTH="100%" CELLSPACING="0" CELLPADDING="0" BORDER="0"><tr><td align="right" valign="middle"><table style="background-color: #008000; border-style: none;" border="0" cellpadding="2" cellspacing="2"><tr><td><img height="5" width="5" border="0" src="https://static.xxx.net/xxx/images/2.60.D1/spacer.gif" title="07:00,24hrs: B Shift /.../E704/RS704/Firefighter #2" alt="07:00,24hrs: B Shift /.../E704/RS704/Firefighter #2"></td></tr></table><img height="2" width="2" border="0" src="https://static.xxxx.net/xxx/images/2.60.D1/spacer.gif" alt=""><img alt="" height="1" width="1" border="0" src="https://static.xxx.net/xxx/images/2.60.D1/spacer.gif"></td><TD ALIGN="RIGHT" VALIGN="TOP" width="17%"><a href="javascript:void(0)" title="01/09/2013" class="daylink" onClick="return DayClick('01/09/2013');">09</a></TD><td rowspan="2" width="5"><img alt="" height="1" width="1" border="0" src="https://static.xxx.net/xxx/images/2.60.D1/spacer.gif"></td></tr><tr><TD COLSPAN="2"><TABLE><TR><TD style="background-color: #FFFFFF; " class="calexception"><a href="javascript:void(0)" onClick="return ShowRemoveExceptionWindow("4A3254517F256810DE1689CEE3FF0E80.fre01","3283507");" title="24hrs Mu, 07:00 - 07:00 /.../M704/Firefighter (pp)" style="color: #000000; text-decoration: none; font-weight: bold;">Mu</a></TD></TR></TABLE></TD></tr>\[/code\]My Objective-c:\[code\]NSString *tutorialsXpathQueryString = @"//a";NSArray *tutorialsNodes = [tutorialsParser searchWithXPathQuery:tutorialsXpathQueryString];NSLog(@"here is url: %@", tutorialsNodes);NSMutableArray *newTutorials = [[NSMutableArray alloc] initWithCapacity:0];for (TFHppleElement *element in tutorialsNodes) { Tutorial *tutorial = [[Tutorial alloc] init]; [newTutorials addObject:tutorial]; tutorial.title = [[element firstChild] content]; tutorial.url = [element objectForKey:@"style"]; tutorial.title = [element objectForKey:@"title"];\[/code\]
 
Back
Top