Skip to content Skip to sidebar Skip to footer

How To Get List Of Elements By Partial Class Name?

I have an HTML document in which there is a table with multiple rows defined as: ...

Solution 1:

"Is it possible to get all the elements (rows) that start with the class name row_?"

Sure, it is possible. You can either use XPath or LINQ to express your query when using HAP :

HtmlDocument doc;
....
....

var resultXPath = doc.DocumentNode
                     .SelectNodes("//tr[starts-with(@class, 'row_')]");
var resultLINQ = doc.DocumentNode
                    .Descendants("tr")
                    .Where(o => o.GetAttributeValue("class","").StartsWith("row_"));

Post a Comment for "How To Get List Of Elements By Partial Class Name?"