html - 查找表中几行的 XPath?

标签 html ios objective-c xpath hpple

我目前正尝试使用 xpath 查询从 html 站点提取特定数据,但在提取特定部分时遇到问题。

使用 //div[@id='main']/h2 作为我的 xpath 查询,我可以使用以下方法提取“查看当前”文本:

exampleSite.title = [[element firstChild] content];

但是我还想引入以下内容:

1. <b>5/9/2013<nbsp><nbsp> 10:58:45 PM</b>
2. <b>6.32</b>
3. <b>5  Total Points</b>
4. <b>3.72</b>

到目前为止我得到了这个://div[@id='main']/table[@class='bodytext']/tr 但这就是我卡住的地方.任何帮助将不胜感激!谢谢!

这是我试图抓取的 html:

<div id="main">
<h2>View Current</h2>

      <table width="96%" border="0" cellpadding="4" cellspacing="0" bordercolor="#eeeeee" align="center" height="276" valign="top" class="bodytext">
        <tr valign="top" >
          <td colspan = 2 height="13" valign="top" align="left" width="54%" class="headerblue" >Balances <br>
          </td>
        </tr>
        <tr valign="top" > 
          <td colspan = 2 height="13" valign="top" align="left" width="54%" class="text" >Balances 
            as of: <b>5/9/2013<nbsp><nbsp> 10:58:45 PM</b></td>
        </tr>
        <tr valign="top" > 
          <td colspan = 2 height="13" valign="top" align="left" width="46%" class="text" >Account 
            Number: <b>101010123</b></td>
        </tr>
        <tr valign="top" > 
          <td colspan = 2 height="13" valign="top" align="left" width="46%" class="text" ></td>
        </tr>

        <tr valign="top" > 
          <td height="13" valign="top" align="left" width="46%" class="text" >Example Card Amount: 
            <b>6.32</b></td>
<td height="13" valign="top" align="left" width="46%" class="text" ><a href="balance.asp?">View Details</a></td>
        </tr>

        <tr valign="top" > 
          <td height="13" valign="top" align="left" width="46%" class="text" >Example Dining Plans:<b>5  Total Points</b>

</td>
<td height="13" valign="top" align="left" width="46%" class="text" ><a href="balance2.asp?">View Details</a></td>
        </tr>

        <tr valign="top" > 
          <td height="13" valign="top" align="left" width="46%" class="text" >Credit For Printing: 
            <b>3.72</b></td>
<td height="13" valign="top" align="left" width="46%" class="text" ><a href="balance1.asp?">View Details</a></td>
        </tr>

          <td colspan = 2 height="13" valign="top" align="CENTER"  class="text">For 
            questions contact Cashiers at<BR> (000)000-0011 or <a href="mailto:example@example.com">example@example.com</a></td>
        </tr>
        <tr valign="top"> 
          <td colspan = 2 height="13" valign="top" align="CENTER"  class="text" > 

<a href="balance1.asp">All Plan Usage for last 90 days is available here</a>
            </td>
        </tr>
        <tr valign="top"> 
          <td colspan = 2 height="13" valign="top" align="CENTER"  class="text" > 

<a href="balance.asp?pln=Full">All Usage for last 365 days is available here</a>
            </td>
        </tr>

      </table>



</div>

最佳答案

//div[@id='main']/table[@class='bodytext']/tr/td/b应该给你一个所有<b>的列表s 在你的表格单元格中。

关于html - 查找表中几行的 XPath?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16479681/

相关文章:

asp.net - 当文档模式为 Edge 时,IE11 中的 ReportViewer 高度问题

javascript - 在.Net Core 2.0 MVC 中删除并添加的下拉列表?

css - 当 <figcaption> 的内容宽度超过 <img> 兄弟的宽度时,使 <figcaption> 呈现滚动条

ios - 如何使用 AFNetworking AFHTTPRequestOperationManager 显示 ProgressBar

ios - 在 Metal 中如何清除深度缓冲区或模板缓冲区?

ios - 面朝上方向 iPhone

javascript 图像 src 更改事件(不是加载事件)

ios - 获取没有 keyboardWillAppear 用户信息通知的键盘框架,iOS

ios - 不允许在某些 View 上进行触摸交互?

iphone - FBWebDialog 在 iOS 7 中出现时消失