Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Parser for local HTML files

Tags:

html

c#

I need to be able to parse an HTML template file (with the intention of injecting an SVG element into a html file, then converting it to pdf via wkhtmltopdf).

I know about the HTML Agility Pack, but it seems incapable of parsing local files (attempts to use file:// URIs have caused it to throw exceptions).

So, can anyone recommend a C# HTML parser for local HTML files?

like image 792
Jordaan Mylonas Avatar asked Dec 10 '22 04:12

Jordaan Mylonas


1 Answers

HTML Agility Pack is fine for local files, check out this example from the docs.

Alternatively, load the content from the file into a string using something like File.ReadAllText then pass it into HtmlDocument.LoadHtml(string html).

like image 157
Chris Fulstow Avatar answered Dec 22 '22 01:12

Chris Fulstow