It throws exception if the tag name or attribute name has illegal chars.
Author : Lalit Patel
Website: http://www.lalit.org/lab/convert-php-array-to-xml-with-attributes
License: Apache License 2.0
http://www.apache.org/licenses/LICENSE-2.0
Version: 0.1 (10 July 2011)
Version: 0.2 (16 August 2011)
- replaced htmlentities() with htmlspecialchars() (Thanks to Liel Dulev)
- fixed a edge case where root node has a false/null/0 value. (Thanks to Liel Dulev)
Version: 0.3 (22 August 2011)
- fixed tag sanitize regex which didn't allow tagnames with single character.
Version: 0.4 (18 September 2011)
- Added support for CDATA section using @cdata instead of @value.
Version: 0.5 (07 December 2011)
- Changed logic to check numeric array indices not starting from 0.
Version: 0.6 (04 March 2012)
- Code now doesn't @cdata to be placed in an empty array
Version: 0.7 (24 March 2012)
- Reverted to version 0.5
Version: 0.8 (02 May 2012)
- Removed htmlspecialchars() before adding to text node or attributes.
Usage:
$xml = Array2XML::createXML('root_node_name', $php_array);
echo $xml->saveXML();