<?php
$sxeA = simplexml_load_string('<nowYouSeeIt><nowYouDont /></nowYouSeeIt>');
$root = dom_import_simplexml($sxeA);
$sxeB = simplexml_import_dom($root);
print "Simplexml A\n";
print $sxeA->asXML() . "\n";
print "Simplexml B\n";
print $sxeB->asXML() . "\n";
print "I simply utter the magic xpath phrases...\n\n";
$items = $sxeA->xpath("//nowYouDont");
$node = dom_import_simplexml($items[0]);
$node->parentNode->removeChild($node);
print "ABBRA-KA-FREAKIN'-DABRA!\n";
print "Simplexml A\n";
print $sxeA->asXML() . "\n";
print "Simplexml B\n";
print $sxeB->asXML() . "\n";
Daniel's collected open source and open data musings as a web developer, project manager and architect in Adelaide.
Tuesday, June 19, 2007
PHP Magic: Watch carefully as I place this DOMNode into a hat
Nab this, save it somewhere (I did it with 5.2.3). Spot my magic trick, and X_import_Y not doing what you'd assume.
Tags
magic,
open source,
php
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment