| |
Decoding XML String Values (PHP version)
|
|
|
I have already explained how to encode values in an XML string (using Javascript) here. So, if you have encoded the values in your XML strings using my javascript function then you can use the PHP function(explained below) to decode the values in those XML string on the server side (i.e. backend PHP side.)
function xmldecode($txt)
{
$txt = str_replace('&', '&', $txt);
$txt = str_replace('<', '<', $txt);
$txt = str_replace('>', '>', $txt);
$txt = str_replace(''', "'", $txt);
$txt = str_replace('"', '"', $txt);
return $txt;
}
Using xmldecode() - A simple example (PHP Code):
So, you can use the function (above) as follows:
$xml = new SimpleXMLElement($xmlstr);
$name_from_js = xmldecode(trim($xml->name));
Please note that SimpleXMLElement is a PHP function that helps parse XML strings.
|
=======================================================================================
Support Geeks Worldwide:Link to us:
You can support us by putting a link to our website on your blog or website (code is below).
<a href="http://www.techsww.com/">
Geeks Worldwide - Tutorials about Software Installation,
Configuration, Administration, Monitoring, Tools, Tips &
Tricks
</a>
OR a simple one.
<a href="http://www.techsww.com/">
Geeks Worldwide - IT related Tutorials
</a>
Feedbacks: We appreciate feedbacks and suggestions about our tutorials and Geeks Worldwide from readers. Please contact us using the form here and let us know what you think about the tutorial and the website in general.
Bookmark Us:
We are working on new features for the website, please keep visiting or bookmark us using your favourite bookmarking service.
Subscribe to RSS:
You can subscribe to our RSS feed here. |
|
|
| |