<?php
// Include the class (using require_once just for good measure)
require_once('xml.php');
// This is just dummy data to show what the class does
$exampleData = array(
'root' => array(
'foobar' => 'foovalue',
'flump' => array('doh'),
'hedk option="something"' => array(
'gnu' => 'gnu is not unix',
'linux' => 'linux is gnu'
),
'1plutt' => 'To create multiple tags with the same name, start with a number',
'2plutt' => 'This is the second tag with the same name, but in the array it\'s starting with a different number',
'numeric' => 'Numeric values are not valid in XML tags, so we treat them as unassociated arrays, creating a tag of the value.',
'1' => 'numeric_tag',
9 => 'another_numeric_tag',
),
);
// Initiate the class
$xml = new xml();
// Set the array so the class knows what to create the XML from
$xml->setArray($exampleData);
// Print the XML to screen
$xml->outputXML('echo');
/**
* This will create:
* <?xml version="1.0" encoding="ISO-8859-1"?>
* <root>
* <foobar>foovalue</foobar>
* <flump>
* <doh />
* </flump>
* <hedk option="something">
* <gnu>gnu is not unix</gnu>
* <linux>linux is gnu</linux>
* </hedk>
* <plutt>To create multiple tags with the same name, start with a number</plutt>
* <plutt>This is the second tag with the same name, but in the array it's starting with a different number</plutt>
* <numeric>Numeric values are not valid in XML tags, so we treat them as unassociated arrays, creating a tag of the value.</numeric>
* <numeric_tag />
* <another_numeric_tag />
* </root>
*
*/
?>
|