-1

我想将每列的列标题和数据行刮成一个二维数组。数据如下所示:

    <div id="content">
<!-- start left col--><div id="LeftCol-wss">
<h1>Aircraft Names</h1>


<h3>Names by Type</h3>
  <table cellspacing="1" cellpadding="2" class="data">
    <tr valign="top" bgcolor="#FFFFFF">
      <td valign="top" width="25%">
        <table width="100%" cellpadding="3" cellspacing="0" border="0" class="data">               
            <tr class="datatop">
            <td width="100%">
              Fighter</td>
          </tr>
          <tr>
              <td align="top" class="datatop" width="100%">
              <br/>              
              <a href="/page/mig-29.html" >MiG-29</a>
            <br/>
              <a href="/page/f-15.html" >F-15</a>
            <br/>
              <a href="/page/f-86.html" >F-86</a>
            <br/>
                <br>
              </td>
          </tr>
        </table>
      </td>
      <td valign="top" width="25%">
        <table width="100%" cellpadding="3" cellspacing="0" border="0" class="data">               
            <tr class="datahead">
            <td width="100%">
              Bomber</td>
          </tr>
          <tr>
              <td align="top" class="datatop" width="100%">
              <br/>
              <a href="/page/b-52.html" >B-52</a>
            <br/>
              <a href="/page/b-1b.html" >B-1B</a>
            <br/>
                <br>
              </td>
          </tr>
        </table>
      </td>
</div>

我正在寻找的结果将是一个二维数组,如下所示:

  • 战斗机 MiG-29
  • 战斗机 F-15
  • 战斗机 F-86
  • 轰炸机 B-52
  • 轰炸机 B-1B

我正在使用 C# 并且更喜欢使用 LINQ,但在这一点上我会接受任何建议。

4

1 回答 1

2

如果您想在 C# 中解析 HTML,规范的答案是使用HTML Agility Pack

于 2012-01-10T04:03:02.583 回答