PHP Classes

File: helper/jsonToXml.php

Recommend this page to a friend!
  Classes of Alexey Starikov   PHP Helper Class   helper/jsonToXml.php   Download  
File: helper/jsonToXml.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Helper Class
Call helper functions that are loaded dynamically
Author: By
Last change:
Date: 5 years ago
Size: 669 bytes
 

Contents

Class file image Download
<?php
// jsonToXml
return function ($json, $options = array(
       
"indent" => " ",
       
"linebreak" => "\n",
       
"typeHints" => false,
       
"addDecl" => true,
       
"encoding" => "UTF-8",
       
"rootName" => "root",
       
//"rootAttributes" => array("version" => "0.91"),
       
"defaultTagName" => "item",
       
"contentName" => "_content",
       
"attributesArray" => "_attributes"
   
)) {
    require_once
"XML/Serializer.php";
   
$serializer = new XML_Serializer($options);
   
$obj = json_decode($json);
    if (
$serializer->serialize($obj)) {
        return
$serializer->getSerializedData();
    } else {
        return
null;
    }
}
?>