Created
June 26, 2013 15:07
-
-
Save ajcrites/5868194 to your computer and use it in GitHub Desktop.
DOMNodeList from `xpath::query` weird parents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$nodes = <<<HTML | |
<div> | |
div | |
<p> ... </p> | |
</div> | |
HTML; | |
$dom = new DOMDocument; | |
$dom->loadHTML($nodes); | |
$xpath = new DOMXPath($dom); | |
foreach ($xpath->query('//*') as $node) { | |
var_dump($node->parentNode); | |
$node->parentNode->removeChild($node); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment