Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How to get all top level divs of container/wrapper using PHP DOM or DOMX path?

user-image
Question added by Deleted user
Date Posted: 2013/06/26
Abdul Salam Koliyadukkam
by Abdul Salam Koliyadukkam , Associate Consultant , Tata Consultancy Services - Other Locations

By using the id of parent div we can get content, try this $xml = new DOMDocument(); $xml->loadHtml($temp); $xpath = new DOMXPath($xml); $html = ''; foreach ($xpath->query('//div[@id="main"]/node()') as $node) { $html .= $xml->saveHTML($node); }

More Questions Like This