【问题标题】:phpQuery: How to parse the tr's class and style clausephpQuery:如何解析 tr 的类和样式子句
【发布时间】:2016-05-14 03:54:47
【问题描述】:

我有一个解析 html 页面的脚本。一节解析各种 tr 元素。假设我们有一个这样的 tr 结构:

<tr class="a test" style="display: none;">
  <td class="numeric"></td>
  <td class="date">1/1/16</td>
  <td class="numeric">$2.65</td>
  .... etc....
</tr>
<tr class="another tr">
  ...... etc......

当前运行良好的代码是这样的:

$the_row_I_want = $parseSectionofCodeImlookingat->find("tr:eq($rowIwant)");
$entire_tr_in_html = $the_row_I_want->__toString();

它的作用是返回整个 tr 的 html,我可以从中解析出类名和样式部分。但是我一直在尝试找出如何使用 phpQuery 语法为我解析类名和样式部分。有没有办法使用 phpQuery(以及如何)来做到这一点?

【问题讨论】:

    标签: phpquery


    【解决方案1】:

    好的,想通了:

    $the_row_I_want = $parseSectionofCodeImlookingat->find("tr:eq($rowIwant)");
    $entire_tr_in_html = $the_row_I_want->__toString();
    $the_class_attribute = $the_row_I_want->attr('class');
    $the_style_attribute = $the_row_I_want->attr('style');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-06-13
      • 1970-01-01
      • 1970-01-01
      • 2011-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多