I don't think there is a way to make HtmlAgilityPack
read invalid element as html element. How about a little hack :
//get the first line string
var firstNodeText = doc.DocumentNode.ChildNodes[0].InnerHtml;
//do simple string manipulation to change invalid element to become a valid html element
//in this example we change this : <%@ .... %> to become : <_asp .... />
HtmlNode firstNode = HtmlNode.CreateNode(firstNodeText.Replace("<%@", "<_asp").Replace("%>", "/>"));