Convert PHP array to XML with support for attributes and CDATA