- Welcome to Geeksww.com
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.
Did this tutorial help a little? How about buy me a cup of coffee?
Please feel free to use the comments form below if you have any questions or need more explanation on anything. I do not guarantee a response.
IMPORTANT: You must thoroughy test any instructions on a production-like test environment first before trying anything on production systems. And, make sure it is tested for security, privacy, and safety. See our terms here.
tags cloud
popular searches
free download for mysql database server 5.1.5, bison, gearman, source code, php, install cairo, laptop, java, mysql, install mysql, linux, mysql initialization, mysql mysql, tools, ubuntu
Similar Tutorials:
- Installing Gearman shared PECL extension for PHP on Debian/Ubuntu Linux
- How to check PHP version number?
- Installing Symfony using PEAR
- Simple Coding Style for PHP - Part 1/2
- Simple Coding Style for PHP - Part 2/2
Tutorials in 'Web Development > PHP' (more):
- Generating prime nos in PHP using multiprocessing - Geaman with PHP client Part I
- PHP Useful functions (Part 2) - The currentURL function
- PHP Useful functions (Part 1) - The inRange function
- Generating Unique IDs in PHP
- How to check PHP version number?
Comments (write a comment):
0 comments so far. Be the first one to leave a comment on this article.
leave a comment