PHP Classes
elePHPant
Icontem

File: sample6.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Tom Schaefer  >  QXML  >  sample6.php  >  Download  
File: sample6.php
Role: Example script
Content type: text/plain
Description: convert Array to Xml to JSON
Class: QXML
XML <> Array (preserve attrib.), JSON, etc.
Author: By
Last change: - removing error (calling wrong class method)
Date: 7 years ago
Size: 1,621 bytes
 

Contents

Class file image Download
<?php

include("QXml.class.php");
include(
"JSON.class.php");
include(
"XMLJSON.class.php");

$caption = "Vacation";

$nodes = array(
 
"@attributes" => array(
   
"dateformat" => "yyyy-mm-dd",
   
"dateformat" => "yyyy-mm-dd",
   
"hoverCapBorderColor" => "2222ff",
   
"hoverCapBgColor" => "e1f5ff",
   
"ganttWidthPercent" => 60,
   
"ganttLineAlpha" => 80,
   
"canvasBorderColor" => "024455",
   
"canvasBorderThickness" => 0,
   
"gridBorderColor" => "4567aa",
   
"gridBorderAlpha" => 20,
  ),
 
"categories" => array(
    array(
     
"@attributes" => array(
       
"bgColor" => "4567aa"
     
),
     
"category" => array(
        array(
         
"@attributes" => array(
           
"start" => "2008-01-01",
           
"end" => "2008-12-31",
           
"align" => "center",
           
"fontColor" => "ffffff",
           
"isBold" => 1,
           
"fontSize" => 14,
           
"name" => $caption,
            )
        ),
        array(
         
"@attributes" => array(
           
"start" => "2008-01-01",
           
"end" => "2008-12-31",
           
"align" => "center",
           
"font" => "Verdana",
           
"fontColor" => "ffffff",
           
"isBold" => 1,
           
"fontSize" => 11,
           
"name" => "Monate",
            ),
        ),
        array(
         
"@attributes" => array(
           
"bgColor" => "4567aa",
           
"fontColor" => "ff0000",
            ),
        ),
       
      )
    )
  )
);

$xml = new QXML;
$xml->toXML($nodes);
echo
$xml->toJSONFromXML($xml->asXML());

?>