PHP Classes

File: helper/xmlToJson.php

Recommend this page to a friend!
  Classes of Alexey Starikov   PHP Helper Class   helper/xmlToJson.php   Download  
File: helper/xmlToJson.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: 598 bytes
 

Contents

Class file image Download
<?php
// xmlToJson
return function ($xml, $options = array(
       
"complexType" => "array",
       
"keyAttribute" => "_attributes",
       
"attributesArray" => "_attributes",
       
// "parseAttributes" => true,
       
"forceEnum" =>array('item'),
       
"ignoreKeys" =>array('item')
    )) {
    require_once
"XML/Unserializer.php";
   
$unserializer = new XML_Unserializer($options);
    if (
$unserializer->unserialize($xml)) {
        return
json_encode($unserializer->getUnserializedData());
    }
    else {
        return
null;
    }
}
?>