views:

145

answers:

1

Hi I am going through a html string with HtmlAgilityPack. Now what I need to get everything between a tagg. It looks like this.

<left>
   <table>..</table>
   <table>..</table>
   <table>..</table>
   <table>..</table>
   <table>..</table>
</left>

Now I use this expression for this task. EDIT:

var htmlResult = doc.DocumentNode.SelectNodes("//left");                

            foreach (var item in htmlResult)
            {
                litStatus.Text += item.InnerHtml;
            }

I get only the 6 first but there are about 24 tables. Why, any ideas?

<left> 

    <table width="100%" border="0" cellspacing="0">

      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-01-29&nbsp; 
          </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">&nbsp;</td>

      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-01-30&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-01-30&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>


    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-01-30&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-01-30&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-02-05&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>


    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-02-06&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-02-27&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-02-27&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>


    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-02-27&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-03-27&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-03-27&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>


    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-03-27&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-04-03&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-05-01&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>


    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-05-08&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-05-18&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-05-22&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>


    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-05-22&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-05-29&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-05-29&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>


    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-06-02&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-06-12&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>


    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-07-02&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-07-03&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-07-07&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>


    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-08-04&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-08-15&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>


    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-08-21&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-08-28&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>

    <table width="100%" border="0" cellspacing="0">
      <tr> 
        <td width="100" valign="top" ><font size="2" face="Verdana">2010-09-01&nbsp; 
          </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">&nbsp;</td>
      </tr>
    </table>


    </left>
+3  A: 

You are selecting a Singlenode, that's why u will only get one element ;).

To get more Nodes:

SelectNodes instead of SelectSingleNode.

Younes
Doh:) but still I dont get as many results as I am suppose to, I get 6 tables but it's about 24
Dejan.S
Are those elements devided over multiple "</left>"'s ?
Younes
No in one, that's whats confusing me
Dejan.S
If your have one root element called <left> with 24 times a <table> element in it, selectnodes should get all table elements indeed.
Younes
OMG I need 2-3 redbulls. It was the html from the wrong site, the site I got it from had 6 of the same events(tables) so thats why I did not even react to it was the wrong site.. thanks for you help
Dejan.S
It's no prblem. help me next time if i have a problem ;)
Younes