Html Agility Pack get all elements by class

前端 未结 5 1644
失恋的感觉
失恋的感觉 2020-12-04 10:48

I am taking a stab at html agility pack and having trouble finding the right way to go about this.

For example:

var findclasses = _doc.DocumentNode.D         


        
5条回答
  •  情书的邮戳
    2020-12-04 11:29

    public static List GetTagsWithClass(string html,List @class)
        {
            // LoadHtml(html);           
            var result = htmlDocument.DocumentNode.Descendants()
                .Where(x =>x.Attributes.Contains("class") && @class.Contains(x.Attributes["class"].Value)).ToList();          
            return result;
        }      
    

提交回复
热议问题