note 63856 added to ref.simplexml
| From: | judofyr at gmail dot com | Date: | Sun, 02 Apr 2006 09:31:48 +0000 |
| Subject: | note 63856 added to ref.simplexml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107154@lists.php.net to get a copy of this message | ||
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 :)
----
Server IP: 85.19.135.21
Probable Submitter: 193.90.229.10
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/ref.simplexml.php
Edit -- http://master.php.net/note/edit/63856
Del: integrated -- http://master.php.net/note/delete/63856/integrated
Del: useless -- http://master.php.net/note/delete/63856/useless
Del: bad code -- http://master.php.net/note/delete/63856/bad+code
Del: spam -- http://master.php.net/note/delete/63856/spam
Del: non-english -- http://master.php.net/note/delete/63856/non-english
Del: in docs -- http://master.php.net/note/delete/63856/in+docs
Del: other reasons-- http://master.php.net/note/delete/63856
Reject -- http://master.php.net/note/reject/63856
Search -- http://master.php.net/manage/user-notes.php