{"id":4429,"date":"2019-12-24T11:42:52","date_gmt":"2019-12-24T19:42:52","guid":{"rendered":"http:\/\/blackcap.name\/blog\/new\/?p=4429"},"modified":"2019-12-24T11:50:32","modified_gmt":"2019-12-24T19:50:32","slug":"so-many-html-parsers-suck","status":"publish","type":"post","link":"https:\/\/blackcap.name\/blog\/new\/?p=4429","title":{"rendered":"So Many HTML Parsers Suck"},"content":{"rendered":"<p>Why? They ram a document tree down your throat, that&#8217;s why. So you&#8217;re stuck writing code that:<\/p>\n<ul>\n<li>Consumes more memory, since you must load the entire document in memory at once, and<\/li>\n<li>Makes modifying the content tricky, since traversing a document tree you are modifying is a potential minefield. (The alternative is to create an entire new document tree from the old one, which doubles the already sometimes obscene memory footprint.), and<\/li>\n<li>Consumes more processor time, because multiple tree traversals are typically necessary.<\/li>\n<\/ul>\n<p>Slow, bloated, error-prone: In a word, document trees just plain suck. Yes, <em>some<\/em>times they are necessary. That just means they should be a necessary <em>alternative<\/em>. They should <em>never<\/em> be the only way you can parse HTML.<\/p>\n<p>Yet, with all too many HTML parsers, they are the only way. And that&#8217;s why so many HTML parsers suck.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Why? They ram a document tree down your throat, that&#8217;s why. So you&#8217;re stuck writing code that: Consumes more memory, since you must load the entire document in memory at once, and Makes modifying the content tricky, since traversing a document tree you are modifying is a potential minefield. (The alternative is to create an [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-4429","post","type-post","status-publish","format-standard","hentry","category-computers"],"_links":{"self":[{"href":"https:\/\/blackcap.name\/blog\/new\/index.php?rest_route=\/wp\/v2\/posts\/4429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blackcap.name\/blog\/new\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blackcap.name\/blog\/new\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blackcap.name\/blog\/new\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blackcap.name\/blog\/new\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4429"}],"version-history":[{"count":0,"href":"https:\/\/blackcap.name\/blog\/new\/index.php?rest_route=\/wp\/v2\/posts\/4429\/revisions"}],"wp:attachment":[{"href":"https:\/\/blackcap.name\/blog\/new\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blackcap.name\/blog\/new\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blackcap.name\/blog\/new\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}