HtmlAgilityPack Get all links inside a DIV

.net, c#, html-agility-pack, xml, xpath

Solution

var div = doc.DocumentNode.SelectSingleNode("//div[@class='myclass']");
if(div!=null)
{
     var links = div.Descendants("a")
                    .Select(a => a.InnerText)
                    .ToList();
}

Problem

I want to be able to get 2 links from inside a div. Currently I can select one but whene there's more it doesn't seem to work. ``` HtmlWeb web = new HtmlWeb(); HtmlDocument doc = web.Load(url); HtmlNode node = doc.DocumentNode.SelectSingleNode("//div[@class='myclass']"); if (node != null) { foreach (HtmlNode type in node.SelectNodes("//a@href")) { recipe.type += type.InnerText; } } else recipe.type = "Error fetching type."; ``` Trying to get it from this piece of HTML: ``` <div class="myclass"> <h3>Not Relevant Header</h3> <a href="#">This text</a>, <a href="#">and this text</a> </div> ``` Any help is appreciated, Thanks in advance.

Original source