dianeinflorida
dianeinflorida

Reputation: 53

simple-html-dom nested

I am trying to use Simple HTML DOM to catch the last part of this pagination. This part:

<a class="paginationNumberStyle page_arrows" data-url="**/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&amp;Nu=P_PARENT_ID&amp;langId=-1&amp;Nao=96&amp;storeId=10051**"> 


    <div class="page-nav">  

                <span>1</span>

                 <a class="paginationNumberStyle" data-url="/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&amp;Nu=P_PARENT_ID&amp;langId=-1&amp;Nao=96&amp;storeId=10051"> 
                    2
                 </a>

                 <a class="paginationNumberStyle" data-url="/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&amp;Nu=P_PARENT_ID&amp;langId=-1&amp;Nao=192&amp;storeId=10051"> 
                    3
                 </a>

                 <a class="paginationNumberStyle" data-url="/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&amp;Nu=P_PARENT_ID&amp;langId=-1&amp;Nao=288&amp;storeId=10051"> 
                    4
                 </a>

                 <a class="paginationNumberStyle" data-url="/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&amp;Nu=P_PARENT_ID&amp;langId=-1&amp;Nao=384&amp;storeId=10051"> 
                    5
                 </a>

        <a class="paginationNumberStyle page_arrows" data-url="/Building-Materials/h_d1/N-5yc1vZ25ecodZaqns/h_d2/Navigation?catalogId=10053&amp;Nu=P_PARENT_ID&amp;langId=-1&amp;Nao=96&amp;storeId=10051"> 
                    <img alt="" src="/static/images/layout/triangle-green-right.gif"></a>



</div>

Here is my code:

if ($nextPage = $dom->find('a[class=paginationNumberStyle.page_arrows]', 0)) {

   echo $nextPage->href;

I have also tried:

if ($nextPage = $dom->find('a[class=paginationNumberStyle.page_arrows]', 0)) {

I am far from an expert on Simple HTML DOM and was hoping that someone knew a quick answer. I am wondering if it is because of the data-url?

Upvotes: 0

Views: 941

Answers (2)

pguardiario
pguardiario

Reputation: 54992

For simplicity you can just:

$dom->find("a.page_arrows", 0)

Upvotes: 1

Sam
Sam

Reputation: 2970

Try as this

if ($nextPage = $dom->find("a[class='paginationNumberStyle page_arrows]", 0)) echo $nextPage->getAttribute('data-url'); 

Upvotes: 1

Related Questions