KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How get first level of dom elements by Domdocument PHP? Example with code that not works - tooken from Q&A: How to get nodes in first level using PHP DOMDocument? <?php $str=<<< EOD <div id="header"> </div> <div id="content"> <div id="sidebar"> </div> <div id="info"> </div> </div> <div id="footer"> </div> EOD; $doc = new DOMDocument(); $doc->loadHTML($str); $xpath = new DOMXpath($doc); $entries = $xpath->query("/"); foreach ($entries as $entry) { var_dump($entry->firstChild->nodeValue); } ?>
Tags (comma-separated)
Save Edits
Cancel