I have an HTML document and I'm getting elements based on a class. Once I have them, I'm going through each element and get further elements:
var doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(content);
var rows = doc.DocumentNode.SelectNodes("//tr[contains(@class, 'row')]");
foreach (var row in rows)
{
var name = row.SelectSingleNode("//span[contains(@class, 'name')]").InnerText,
var surname = row.SelectSingleNode("//span[contains(@class, 'surname')]").InnerText,
customers.Add(new Customer(name, surname));
};
However, the above is iterating through the rows but the always retrieving the text of the first row.
Is the XPath wrong?