2026-06-09 15:21 UTC
Today's hard learned lesson with parsing #html in #php :
When you query xpath (DOMDocument, DOMXpath) by class you need exact same class value with all the classes as in html. I mean it's kind of obvious but also unintuitive.
Replies (2)
-
@Crell@phpc.social 2026-06-09 20:59
@len@toot.si Try the new HTML 5 friendly parser in PHP 8.5. I'm not sure if it has special class handling, but it's what you should be using for parsing HTML these days.
-
@noctuaminervae@toot.si 2026-06-10 05:42
@len@toot.si In the sense that //*[@class="foo"] will not select an element with class="foo baz" , or something else?