您好我正在浏览一个带HtmlAgilityPack的html字符串。现在我需要在tagg之间获取所有内容。它看起来像这样。
<left>
<table>..</table>
<table>..</table>
<table>..</table>
<table>..</table>
<table>..</table>
</left>
现在我将此表达式用于此任务。 修改
var htmlResult = doc.DocumentNode.SelectNodes("//left");
foreach (var item in htmlResult)
{
litStatus.Text += item.InnerHtml;
}
我首先得到的只有6张,但大约有24张桌子。为什么,任何想法?
<left>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-01-29
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Årets första Rockabillyfest på Carinas!!! Vänersborg</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2827'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-01-30
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Swapmeet, Karlstad</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2824'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-01-30
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Vintermarknad, Emmaboda</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2790'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-01-30
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Rock`n Roll Party, Göteborg</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2803'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-01-30
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Rockabilly fest Kungälv</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2784'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-02-05
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Countrykväll med WOODSTATE, Säter</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2830'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-02-06
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">House of Blues, Oskarshamn</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2837'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-02-27
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Rock`n Roll Party, Göteborg</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2833'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-02-27
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Vårrock, Varekil</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2831'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-02-27
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">ROCK´N´ROLL SHOW TROLLHÄTTAN</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2825'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-03-27
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Bilutstälnning mitt i Tärnsjö m crusing</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2787'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-03-27
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">ROCKABILLY NIGHT, Blomstermåla</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2832'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-03-27
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Grillfesten, Karlskoga</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2838'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-04-03
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">WHEELERS PÅSKFEST</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2769'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-05-01
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">WHEELERS CRUISING, VETLANDA</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2774'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-05-08
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Örebro springmeet no:4</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2836'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-05-18
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">TISDAGSTRÄFF I SÄTERDALEN</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2829'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-05-22
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">KRISTINEHAMNS TRÄFFEN, Kristinehamn</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2834'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-05-22
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Söderhamns Cruising, Söderhamn</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2835'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-05-29
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Sollefteå big meet</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2788'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-05-29
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">May Graduation 2010, Göteborg</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2826'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-06-02
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Åkdon & Termos, Hudiksvall</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2761'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-06-12
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Nostalgifest i Pilaboparken, Nässjö</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2839'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-07-02
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">FALQVISTS GLAS TROOPHY 2010, KARLSKOGA</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2791'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-07-03
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Pistohiekka Rock n roll&Cruise, Finland</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2802'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-07-07
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Åkdon & Termos, Hudiksvall</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2764'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-08-04
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Åkdon & Termos, Hudiksvall</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2763'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-08-15
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Classic Wing Meet 2010, Gullspång 13-15 aug</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2823'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-08-21
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">FORDONSUTSTÄLLNING, Skövde</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2828'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-08-28
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">GÖTEBORGSCRUISINGEN</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2822'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="100" valign="top" ><font size="2" face="Verdana">2010-09-01
</font> </td>
<td valign="top" width="342" >
<div align="left"><font size="2" face="Verdana">Åkdon & Termos, Hudiksvall</font> <font size='2' face='Verdana'><A HREF='kalender_detalj.asp?ID=2762'>Mer info!</A></font></div>
</td>
</tr>
<tr>
<td style="Font-size: 1pt" face="Verdana" width="100"> </td>
</tr>
</table>
</left>
答案 0 :(得分:4)
您正在选择Singlenode,这就是为什么您只会获得一个元素;)。
获取更多节点:
SelectNodes而不是SelectSingleNode。