How can I split an HTML element?

How can I get the inner text of an HTML element using Simple HTML DOM parser?

  • I have html like <div class="cost_decoration"> <span class="msrp">$85</span> 40% off </div> My Question is ... How to get tex 40% off from above. When I try I am getting like "$85 40% off" but I want to get only term 40% off.

  • Answer:

    $cost = $html->find(div[class="cost_decoration"], 0); if($cost->childNodes(0)->tag) { echo "do not echo"; } else { echo $cost->plaintext; }

Gian Carlo Dimaculangan at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.