getElementsByClass() public method

Simple wrapper function that returns all elements by class name.
public getElementsByClass ( string $class ) : array
$class string
return array
Esempio n. 1
0
 /**
  * Get the value of Steps
  *
  * @return mixed
  */
 public function getSections()
 {
     $data = array();
     $body = $this->dom->getElementById('bodycontents');
     $dom = new Dom();
     $dom->load($body);
     $sections = $dom->getElementsByClass('steps');
     $flag = 0;
     foreach ($sections as $key => $step) {
         $ol_var = $dom->load($step)->getElementsByClass('steps_list_2');
         $li_var = $dom->load($ol_var)->getElementsByTag('li');
         foreach ($li_var as $key => $value) {
             $data[$flag]['stepNumber'] = $flag + 1;
             $data[$flag]['header'] = $dom->load($value)->getElementsByClass('whb')->text;
             $data[$flag]['media'] = $dom->load($value)->getElementsByTag('img')->getAttribute('src');
             $data[$flag]['body'] = $dom->load($value)->getElementsByClass('step')->text;
             $flag++;
         }
         //echo $content;
     }
     return $data;
 }
Esempio n. 2
0
 public function testGetElementsByClass()
 {
     $dom = new Dom();
     $dom->load('<div class="all"><p>Hey bro, <a href="google.com" id="78">click here</a></div><br />');
     $this->assertEquals('<p>Hey bro, <a href="google.com" id="78">click here</a></p>', $dom->getElementsByClass('all')[0]->innerHtml);
 }