如何在ExtJS中解析和转换HTML字符串

时间:2014-02-20 15:16:03

标签: extjs extjs3

我有这个XML字符串,想要解析和遍历它

<table>
  <tbody>
    <tr>
      <th colspan="1">Issue ID</th>
      <th>Role</th>
      <th>Abstract</th>
      <th>Status</th>
      <th colspan="1">Assigned To</th>
      <th>Estimate</th>
      <th colspan="1">Start Date</th>
      <th colspan="1">End Date</th>
      <th colspan="1">Actual</th>
      <th colspan="1">Milestones</th>
    </tr>
    <tr>
      <td class="highlight-blue" data-highlight-colour="blue">265884</td>
      <td class="highlight-blue" data-highlight-colour="blue"> </td>
      <td class="highlight-blue" data-highlight-colour="blue">Task 1</td>
      <td class="highlight-blue" data-highlight-colour="blue"> </td>
      <td class="highlight-blue" data-highlight-colour="blue"> </td>
      <td class="highlight-blue" data-highlight-colour="blue"> </td>
      <td class="highlight-blue" data-highlight-colour="blue"> </td>
      <td class="highlight-blue" data-highlight-colour="blue"> </td>
      <td class="highlight-blue" data-highlight-colour="blue"> </td>
      <td class="highlight-blue" data-highlight-colour="blue"> </td>
    </tr>
    <tr>
      <td> </td>
      <td>QA</td>
      <td>Verify fix</td>
      <td>In-Progress</td>
      <td>Karl</td>
      <td>1</td>
      <td>Feb 11</td>
      <td> </td>
      <td>0.25</td>
      <td>
        <ul>
          <li>Feb 11: Change Code Review to "No Review Required"</li>
          <li>Feb 11: Requested SB for testing</li>
          <li>Feb 13: Still waiting for SB</li>
          <li>Feb 18: (need to follow up) -&gt; Done Re-requested SB copy</li>
        </ul>
      </td>
    </tr>    
  </tbody>
</table>

我想得到<tr>的数量以及数组中的for-loop来访问每一列。我查看了XmlReader但不太确定如何在不使用GridPanel的情况下使用它。 也许Ext.data.Store可以单独实现,但我仍然不太熟悉它,并且在这里找不到任何合适的方法:http://extjs.cachefly.net/ext-3.3.1/docs/?class=Ext.data.XmlReader

1 个答案:

答案 0 :(得分:1)

也许你可以使用Ext选择器(http://docs.sencha.com/extjs/3.4.0/#!/api/Ext-method-select)。

您案例的示例代码:https://fiddle.sencha.com/#fiddle/4pv