<?php
include_once 'c_xml.php';
echo '<html>';
$xml=file_get_contents('demo.xml');
echo "input xml<br><textarea rows='10' cols='100'>$xml</textarea><br><br>";
/*1. show xml-dump*/
echo "xml-dump:<br>";
echo c_xml::dump($xml,true);
echo "<br><br>";
/*2. convert xml to array*/
$o_xml=new c_xml($xml);
$array=$o_xml->toArray(array('bike'));
echo "xml to array<br><textarea rows='10' cols='100'>";
print_r($array);
echo "</textarea><br><br>";
/*3. change array. Convert array to xml*/
foreach ($array as $key=>$item){
if (c_xml::is_system_key($key)) continue;
$array[$key]['@year']=2011;
$array[$key]['owner']['.']='Koreyko';
}
$o_new_xml=new c_xml_node();
$o_new_xml->fromArray('new_bikes',$array);
$new_xml=$o_new_xml->toXML();
echo "new xml<br><textarea rows='10' cols='100'>$new_xml</textarea><br><br>";
/*4. xml*xsl processing*/
echo "xsl-processing:<br>";
echo xsl_out('demo.xsl','data',$array);
echo "<br><br>";
echo '</html>';
|