1

我正在尝试从元素中获取“标题”字段和“背景颜色”样式。- 我对objective-c很陌生,这很容易......

我的 HTML(示例重复不同<TD class='class name'>

   </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(&quot;4A3254517F256810DE1689CEE3FF0E80.fre01&quot;,&quot;3283507&quot;);" 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>

我的目标-c:

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"];
4

0 回答 0