|
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. Please feel free to use the comments form below if you have any questions or need more explanation on anything.
|
Tags
php,
Popular Searches
php, linux, mysql, ubuntu, mysql mysql, tools, install mysql, gearman, source code, java
more>> |
Comments (write a comment):
0 comments so far. Be the first one to leave a comment on this article.