Exemple #1
0
 /**
  * Encode data as XML and return XML text
  *
  * @param Array/Object $data the data to encode
  * @param String $root the root element name (default is "root")
  * @return String the encoded data as XML text
  */
 public static function to_xml($data, $root = Symbol::ROOT)
 {
     load_tool('XML');
     return XML::serialize($data, array('rootName' => $root));
 }
Exemple #2
0
<?php

header('Content-Type: text/xml');
load_tool('XML');
// Get the data to encode into XML
if (!isset($data)) {
    $data = array();
}
// Now for our elegant XML encoding
echo XML::serialize($data);