I have a collection of HTML items after running an XPATH expression against an instance of HtmlDocument (HTMLAgilityPack).
The returning collection is:
The {h3} tag should be name of the item in my type, and the {div} should be the content, but I can’t seem to figure out how to group these guys together?
My anon-type:
var nodes = xhtml.DocumentNode.SelectNodes("//div[@id='membInfo']/h3 | //div[@id='membInfo']/div");
(from node in nodes
select new
{
Name = node[j],
Content = node[j + 1]
});
You can do something like:
The above code LINQ code will give you an anonymous type, where both
NameandContentwill be of typeHtmlNode. You might want to take a look at the propertiesInnertext,OuterHtml, etc. depending on what you want to do next.