C# Is there a LINQ to HTML, or some other good .Net HTML manipulation API?

Solution 1:

Even though it's not LINQ based, I suggest researching the HTML Agility Pack from CodePlex.

Note: Html Agility Pack now supports Linq to Objects (via a LINQ to Xml Like interface)

From the HTML Agility Pack page:

This is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor XSLT to use it, don't worry...). It is a .NET code library that allows you to parse "out of the web" HTML files. The parser is very tolerant with "real world" malformed HTML. The object model is very similar to what proposes System.Xml, but for HTML documents (or streams).

Solution 2:

There's a LINQ to HTML library here:

http://www.superstarcoders.com/linq-to-html.aspx

Solution 3:

HTML is rarely well-formed enough that you could reliably use LINQ to XML. It's conceivable that you might find an HTML "cleaner" that could fix the formatting well enough to be read, but there's not telling how robust it would be.

I assume this is a "screenscraper" that reads from an HTML table over which you have no control. Don't stress over robustness in this case, screen-scraping is inherently brittle. If your requirements are set in stone, design the scraper to be easily updatable if/when the HTML you are scraping changes.