greenheart Posted October 7, 2009 Share Posted October 7, 2009 hello I am searching for all instances of tags with the EXACT class "hello" using simple_html_dom class foreach($html->find('.hello')as $found The above doesn't quite do this because it also gives me classes like "hello world". It is simple yes to count through and list the correct element from the array but the source html that is being parsed changes so that's not practical. Any ideas how to find an exact term for the class? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/176770-parsing-with-simple-html-dom/ Share on other sites More sharing options...
greenheart Posted October 7, 2009 Author Share Posted October 7, 2009 Figured it out myself Quote Link to comment https://forums.phpfreaks.com/topic/176770-parsing-with-simple-html-dom/#findComment-932036 Share on other sites More sharing options...
prueba2387 Posted January 27, 2014 Share Posted January 27, 2014 How did you achieve it? I am trying to accomplish the same. Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/176770-parsing-with-simple-html-dom/#findComment-1466749 Share on other sites More sharing options...
.josh Posted January 27, 2014 Share Posted January 27, 2014 well, technically it's working as intended. <div class="hello world"> $elems = $html->find('.hello'); This will return that div because "hello world" is not one class. It's 2 separate classes, "hello" and "world". So perhaps you meant to ask for it to return elements that only contain one class ("hello")? If that is the case, I think what you want to do is (untested) $elems = $html->find('*[class=hello]'); Edit: Just noticed that you rezzed an old thread, prueba. So I added what should work for you, since it's unlikely the OP will be responding. Quote Link to comment https://forums.phpfreaks.com/topic/176770-parsing-with-simple-html-dom/#findComment-1466758 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.