Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我可以使用HtmlAgilityPack在某个标记上拆分HTML文档吗?_C#_.net_Html_Html Agility Pack - Fatal编程技术网

C# 我可以使用HtmlAgilityPack在某个标记上拆分HTML文档吗?

C# 我可以使用HtmlAgilityPack在某个标记上拆分HTML文档吗?,c#,.net,html,html-agility-pack,C#,.net,Html,Html Agility Pack,例如,我想收集一堆标记。我需要将这些标记中的每一个拆分为单独的元素,以便于我进行分析 这可能吗 标记的一个示例: <tr class="first-in-year"> <td class="year">2011</td> <td class="img"><a href="/battlefield-3/61-27006/"><img src= "http://media.giantbomb.com/uploads/6/

例如,我想收集一堆
标记。我需要将这些标记中的每一个拆分为单独的元素,以便于我进行分析

这可能吗

标记的一个示例:

<tr class="first-in-year">
  <td class="year">2011</td>

  <td class="img"><a href="/battlefield-3/61-27006/"><img src=
  "http://media.giantbomb.com/uploads/6/63038/1700748-bf3_thumb.jpg" alt=""></a></td>

  <td class="title">
    <a href="/battlefield-3/61-27006/">Battlefield 3</a>

    <p class="deck">Battlefield 3 is DICE's next installment in the franchise and
    will be on PC, PS3 and Xbox 360. The game will feature jets, prone, a
    single-player and co-op campaign, and 64-player multiplayer (on PC). It's due out
    in Fall of 2011.</p>
  </td>

  <td class="date">Expected: Q4 2011</td>

  <td><a href="/pc/60-94/" class="PC">PC</a>, <a href="/xbox-360/60-20/" class=
  "X360">X360</a>, <a href="/playstation-3/60-35/" class="PS3">PS3</a></td>
</tr>

<tr>
  <td class="year"></td>

  <td class="img"><a href="/forza-motorsport-4/61-33400/"><img src=
  "http://media.giantbomb.com/uploads/0/1992/1654849-forza4_thumb.jpg" alt=
  ""></a></td>

  <td class="title">
    <a href="/forza-motorsport-4/61-33400/">Forza Motorsport 4</a>

    <p class="deck">The next installment of Turn 10's racing franchise slated for
    release in Fall 2011. It is set to feature 16 player online races, dynamic race
    conditions, cars from over 80 manufacturers, and compatibility with Kinect, both
    on and off the racetrack.</p>
  </td>

  <td class="date">Expected: Oct 2011</td>

  <td><a href="/xbox-360/60-20/" class="X360">X360</a></td>
</tr>

<tr>
  <td class="year"></td>

  <td class="img"><a href="/max-payne-3/61-23398/"><img src=
  "http://media.giantbomb.com/uploads/0/1400/938434-custom_1237811317319_mp3_poster_thumb.jpg"
  alt=""></a></td>

  <td class="title">
    <a href="/max-payne-3/61-23398/">Max Payne 3</a>

    <p class="deck">The long awaited third instalment in Remedy's beloved series, in
    which an aging Max Payne faces one final chance to redeem himself.</p>
  </td>

  <td class="date">Expected: 2011</td>

  <td><a href="/pc/60-94/" class="PC">PC</a>, <a href="/playstation-3/60-35/" class=
  "PS3">PS3</a>, <a href="/xbox-360/60-20/" class="X360">X360</a></td>
</tr>

2011

战地3是DICE在该系列中的下一部 将安装在PC、PS3和Xbox 360上。该游戏将以喷气式飞机、俯卧式飞机和俯卧式飞机为特色 单人和合作活动,以及64人多人游戏(在PC上)。到期了 2011年秋天

预计:2011年第4季度 ,

第10轮赛车特许经营权的下一期将于 2011年秋季发布。它的特点是16人在线比赛,动态比赛 条件、80多家制造商的汽车以及与Kinect的兼容性 在赛道上和赛道下

预计:2011年10月

人们期待已久的《补救》最受欢迎的系列中的第三期,年 一个上了年纪的马克斯·佩恩面临着最后一次救赎自己的机会

预计:2011年 ,

因此,对于这个示例,这里有三个元素:)

如果这是您的意思,那么您不能将其拆分为标签上的多个HTML文档。您可以选择各个TD元素并分别解析它们

XPath选择器
//td
将选择可以传递到解析方法中的所有元素

HtmlAgilityPack.HtmlDocument doc = LoadHtmlHowever();
doc.DocumentNode.SelectNodes("//td");