C# html agility pack get elements by class name

前端 未结 5 938
忘了有多久
忘了有多久 2021-01-04 05:33

I\'m trying to get all the divs that their class contains a certain word:

content1
5条回答
  •  庸人自扰
    2021-01-04 06:00

    HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
    htmlDoc.Load(filePath);
     foreach(HtmlNode link in doc.DocumentElement.SelectNodes("//div[@class='hello']")
     {
        //code
     }
    

提交回复
热议问题