0

I am parsing some html code with simplehtmldom, I find some issue, here some short test code:

$html =<<<ECHO
<div class="content">content 1</div>
<div class="Content">content 2</div>
ECHO;
$str= str_get_html($html);
foreach($str->find('.content') as $content){
    echo $content.'<br />';  // lost .Content
}

So how to solve lowercase and uppercase in simplehtmldom? thanks.

yuli chika
  • 9,053
  • 20
  • 75
  • 122

1 Answers1

0

refrence http://simplehtmldom.sourceforge.net/#fragment-12 we could first strtolower all the elements class.

$html =<<<ECHO
<div class="content">content 1</div>
<div class="Content">content 2</div>
ECHO;
$str= str_get_html($html);
foreach($str->find('div') as $divwithclass){
    $divwithclass->class = strtolower($divwithclass->class);
}
foreach($str->find('.content') as $content){
    echo $content.'<br />';
}
Giberno
  • 1,323
  • 4
  • 17
  • 31