Jump to content

parsing with simple html dom


greenheart

Recommended Posts

 

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

 

Link to comment
Share on other sites

  • 4 years later...

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.