note 63856 deleted from ref.simplexml by bjori

From: Date: Sun, 02 Apr 2006 14:40:41 +0000
Subject: note 63856 deleted from ref.simplexml by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-107164@lists.php.net to get a copy of this message
Note Submitter: judofyr at gmail dot com Reason: bad code ---- Hi! I have make a very nice function to fix namespaces: <?php function namespace($url, $get = false) { if ($get === true) { $file = file_get_contents($url); } else { $file = $url; } $file = preg_replace("#<(\w+):(\w+)>#", "<$1_$2>", $file); $file = preg_replace("#</(\w+):(\w+)>#", "</$1_$2>", $file); return simplexml_load_string($file); } ?> This will replace all : in the tags to _. Works very well. If $url is an url then set $get to true. If $url is a string with some XML, then set $get to false :)

« previous php.notes (#107164) next »