In PHP I’m using DOMDocument and I need to search for an element that has attribute class=”something”
I’m new with DOMDocument (been using REGEX all my life so help me :P)
Ok, my question is, I’ve found a DOMElement using getElementById, now i want to look inside the children of this element and retrieve a node that has a particular class, class=”something”
How do i do that?
Once you have a
DOMNode$nfor a document$dwhose children you want to filter by class you can do (this searches recursively):The point of
containsis to catch those nodes whose class attribute has more than one value, but it’s a bit too coarse. See here for a better solution.