Get String after a HTML tag using a parser

150 views Asked by At

I am using PHP Simple HTML DOM to developing a scraper application.

Below is html structure,we need to get City/State name. its "Daviston, AL" in below example. can anyone please help me here.

<div class="post-entry">
    <h2 class="entry-title">
        <a title="Horseshoe Bend National Military Park" href="http://www.parks.us/id-2755/">Horseshoe Bend National Military Park</a>
    </h2>
    <strong>City/State: </strong> Daviston, AL
    <p><span><em>Activities include:</em> Auto Touring, Biking, Boating, Fishing, Hiking, Picnicking, Water Sports, Wildlife Viewing</span></p>
</div>

with this code , i am just getting "City/State"

foreach($html->find('div[class=post-entry]') as details){
    $Details->find('strong',0)->plaintext
}
1

There are 1 answers

0
venca On
  • Traverse children of div[class=post-entry].
  • Skip h2
  • Skip strong
  • Get text node (Daviston, AL)