Html Agility Pack - loop through rows and columns

前端 未结 2 968
别那么骄傲
别那么骄傲 2021-01-16 02:13

How can I loop through table and row that have an attribute id or name to get inner text in deep down in each td cell? I work on asp.net, c#, and the newest html agility pac

2条回答
  •  情深已故
    2021-01-16 03:07

    It worked! Thank you very much Oded.

        HtmlDocument doc = new HtmlDocument();
             doc.Load(@"C:/samplefolder/sample.htm"); 
    foreach(HtmlNode cell in doc.DocumentNode.SelectNodes("//tr[@name='display']/td")) 
    {
             string test = cell.InnerText;
             Response.Write(test); 
    }
    

    It showed result like JanFebMarAprMayJuneJulAugSepOctNovDec. How can I sort them out, separate by a space or a tab? Thank you.

提交回复
热议问题