4 ms·
Also, HTML has its own, well-defined parsing algorithm [1], which is incompatible with XML, e.g. see [2]. Anything that claims to be able to parse both HTML and
by twiss 5y ago
Also, HTML has its own, well-defined parsing algorithm [1], which is incompatible with XML, e.g. see [2]. Anything that claims to be able to parse both HTML and XML, without knowing which one it is, is lying.
1: https://html.spec.whatwg.org/multipage/parsing.html https://html.spec.whatwg.org/multipage/parsing.html
2: https://news.ycombinator.com/item?id=30600589 https://news.ycombinator.com/item?id=30600589
- deleted 5y ago[deleted]
- Shared404 5y agoNot sure how I didn't know there was already a defined algorithm for parsing HTML. I may try implementing that at some point - I've always been interested, but also got burned out as soon as I tried to work out a viable algorithm. Reason #255 to look things up right away.
- emmanueloga_ 5y agooops... I saw a markup parser and automatically thought XML, but you are right! HTML is actually a whole different beast! As it turns out, seems like nim also has an html parser [1], but I'm guessing something like Google's gumbo [2] could be more reliable, but you would have to write bindings for nim. 1: https://nim-lang.org/docs/htmlparser.html https://nim-lang.org/docs/htmlparser.html 2: https://github.com/google/gumbo-parser https://github.com/google/gumbo-parser