Skip to content Skip to sidebar Skip to footer

Parsing HTML In C# ASP.net

here's my sample HTML...

Solution 1:

Using latest HtmlAgilityPack, just using the document structure - this will not be very resilient to changes in the HTML - you should strongly consider adding appropriate ids (if this is your html anyway):

HtmlDocument doc = new HtmlDocument();
doc.Load(@"test.html");

var tds = doc.DocumentNode.Descendants("td").ToArray();
string codeValue = "";

for (int i = 1; i < tds.Length; i++)
{
    if (tds[i - 1].Element("b").InnerText == "Code:")
        codeValue = tds[i].Element("b").InnerText;
}

Post a Comment for "Parsing HTML In C# ASP.net"