PHP Classes

File: sample3b.php

Recommend this page to a friend!
  Classes of Tom Schaefer   QXML   sample3b.php   Download  
File: sample3b.php
Role: Example script
Content type: text/plain
Description: Showing how to extend xml for FusionChart (XSL,XML)
Class: QXML
XML <> Array (preserve attrib.), JSON, etc.
Author: By
Last change:
Date: 15 years ago
Size: 2,232 bytes
 

Contents

Class file image Download
<?php

include_once("QTransform.class.php");

$INXML = "residential.xml";
$INXSL = "residential.xsl";

// load xml
$xml = simplexml_load_file($INXML);

// add data to xml

// First Category Node
// Already having a category node in XML; need not to be created, just add attributes
$categories = $xml->categories[0];
$categories->category[0]->addAttribute("start","2008-03-10");
$categories->category[0]->addAttribute("end","2008-03-14");
$categories->category[0]->addAttribute("name","2008");
$categories->category[1]->addAttribute("start","2007-03-10");
$categories->category[1]->addAttribute("end","2007-03-14");
$categories->category[1]->addAttribute("name","2007");

// 2. Category Nodes
// Node and Attributes have to be created
$category = $xml->categories[1]->addChild("category");
$category->addAttribute("start","2008-03-10");
$category->addAttribute("end","2008-03-14");
$category->addAttribute("name","2008");
$category = $xml->categories[1]->addChild("category");
$category->addAttribute("start","2008-03-10");
$category->addAttribute("end","2008-03-18");
$category->addAttribute("name","2008");
$category = $xml->categories[1]->addChild("category");
$category->addAttribute("start","2008-03-10");
$category->addAttribute("end","2008-04-18");
$category->addAttribute("name","2008");




$process = $xml->processes->addChild("process");
$process->addAttribute("name","Ashok");
$process->addAttribute("id",1);

$process = $xml->processes->addChild("process");
$process->addAttribute("name","Thomas");
$process->addAttribute("id",2);

$dataColumn = $xml->dataTable->addChild("dataColumn");
$dataColumn->addAttribute("headerText","Team");

$text = $dataColumn->addChild("text");
$text->addAttribute("label","Management");
$text = $dataColumn->addChild("text");
$text->addAttribute("label","Product Manager");
$text = $dataColumn->addChild("text");
$text->addAttribute("label","Core Development");
$text = $dataColumn->addChild("text");
$text->addAttribute("label","Web Team");
$text = $dataColumn->addChild("text");
$text->addAttribute("label","Q&A");

// Transform
header("content-type:text/xml");
$qt = new QTransform();
echo
$qt->toXML($xml, $INXSL);

?>