How to get the value of a tag with a specific class / attribute with DOM and php?

0

Hello. Is it that I want to get the value of a particular tag with a specific class / attribute using DOM and php. Below is the html that will be used:

           <div class="header nopadding filmesonline">
                <div class="letter"><i class="fa fa-film">Filmes para ver</i> FILMES</div>
                <div class="button hover active" data-type="movies" data-what="featured">LANÇAMENTOS</div>
                <div class="button hover" data-type="movies" data-what="recent">Recentes</div>
                <div class="button hover" data-type="movies" data-what="mostseen">Mais vistos</div>
                <div class="button hover" data-type="movies" data-what="recommended">Recomendados</div>
            </div>

php

<?php
$allAElements=$d->getElementsByTagName('div');
if ($allAElements){ 
    foreach ($allAElements as $elemento){
        $dataLoader= $elemento->getAttribute('data-loader'); 
        $dataWhat=$elemento->getAttribute('data-what');
        $class=$elemento->getAttribute('class');
        if($class==="header nopadding filmesonline"){
        if($class==="button hover active") $lancamento = $class->nodeValue; 
        var_dump($lancamento);
    }
} 
?>

And I want with DOM and php to get the values: Movies to see, Movies, LAUNCHES, Most viewed and Recommended and save each one in a variable. The Html is much larger but I'd like to get those values that are in specific classes and tags.

Thank you for your help, this is to do a job for college.

    
asked by anonymous 16.05.2017 / 04:33

0 answers