简体   繁体   中英

PHP Html DOM parsing plain text

I am trying to parse html file using simple html dom parser.Below is the html code. I want to get the plain text after p tag ie "Check out www.freeportusa.com/packages-and-deals for the great offer from J.Crew for Men, Women & Children!". However i managed to get the promotion title ie "DEALS FROM J.CREW!". Any suggestion how to get that text after paragraph tag.

foreach($html->find('#sidebar h3') as $h3_cont)
    {
        if($h3_cont->next_sibling()->class == 'separator special')
        {
            $mem_det['promotions'] .= $h3_cont->next_sibling()->next_sibling()->innertext.'<br />';
            $mem_det['promotions_desc'] .= ??
        }
    }

<div id="sidebar">

    <h3 style="">PROMOTIONS</h3>
                <p><strong style="text-transform:uppercase">Deals from J.Crew!</strong></p>

                Check out  www.freeportusa.com/packages-and-deals for the great offer from J.Crew for Men, Women &amp; Children!  </div>

You can't get it because it's not an element. Your best bet is to get the parent div and strip out all the child elements.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM