| Server IP : 85.112.90.236 / Your IP : 192.168.1.26 Web Server : Apache System : Linux 85-112-90-236.cprapid.com 6.12.0-211.7.3.el10_2.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 19 12:46:58 EDT 2026 x86_64 User : ftechme ( 1002) PHP Version : 8.2.32 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /proc/thread-self/root/usr/share/doc/cpanel-php84-xml-serializer/examples/ |
Upload File : |
<?PHP
/**
* XML Serializer example
*
* This example makes use of the CData sections option
*
* @author Stephan Schmidt <schst@php.net>
*/
error_reporting(E_ALL);
require_once 'XML/Serializer.php';
$serializer = new XML_Serializer();
$serializer->setOption(XML_SERIALIZER_OPTION_INDENT, ' ');
$serializer->setOption(XML_SERIALIZER_OPTION_DEFAULT_TAG, 'item');
$serializer->setOption(XML_SERIALIZER_OPTION_CDATA_SECTIONS, true);
$data = array(
'foo' => 'This is some text...',
'bar' => '& even more text...',
'test' => array('Foo', 'Foo & bar')
);
$result = $serializer->serialize($data);
if( $result === true ) {
$xml = $serializer->getSerializedData();
echo '<pre>';
echo htmlspecialchars($xml);
echo '</pre>';
} else {
$result->getMessage();
exit();
}
?>