potworny
asked on
PHP Simple HTML DOM Parser - select div with multiple classes
Hi,
I have a div:
I want to find this div with the PHP Simple HTML DOM Parser.
The following code does not work:
Can you help me, brothers and sisters? :)
I have a div:
<div class="mada rock rolling">Amateur question</div>
I want to find this div with the PHP Simple HTML DOM Parser.
The following code does not work:
$html->find('div.mada.rock.rolling');
Can you help me, brothers and sisters? :)
If above don't work:
$html->find('div[class=.ma da.rock.ro lling]');
$html->find('div[class=.ma
ASKER
brendonfeeley, I am looking at your answer :)
gr8gonzo, jkdt0077, this does not work:
$html->find("div[class='ma da rock rolling']");
$html->find("div[class='ma da .rock .rolling']")
$html->find('div[class=.ma da.rock.ro lling]');
$html->find('div.mada .rock .rolling');
gr8gonzo, jkdt0077, this does not work:
$html->find("div[class='ma
$html->find("div[class='ma
$html->find('div[class=.ma
$html->find('div.mada .rock .rolling');
What about these:
$html->find('div.mada, div.rock, div.rolling');
$html->find('div[class=mad a], div[class=rock], div[class=rolling]');
$html->find('div.mada, div.rock, div.rolling');
$html->find('div[class=mad
Also, and forgive me if you know this, but:
$html->find('div.mada, div.rock, div.rolling');
Will return an array of matches. In order to output all matches, you will need to loop through them:
foreach($html->find('div.m ada, div.rock, div.rolling') as $element) {
echo $element->plaintext . '<br/>';
}
$html->find('div.mada, div.rock, div.rolling');
Will return an array of matches. In order to output all matches, you will need to loop through them:
foreach($html->find('div.m
echo $element->plaintext . '<br/>';
}
ASKER
I don't think this lib can parse more than one class name...
I just load the HTML into a variable, replace the three classes with one name of my own and parse the modififed version of the HTML. :)
I just load the HTML into a variable, replace the three classes with one name of my own and parse the modififed version of the HTML. :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THANK you very much :)
$html->find('div[class=mad
or try:
$html->find('div.mada .rock .rolling');