Hi all,
I have been writing a CMS for generating XML files to be used by actionscript, so far I can create new, edit, etc. One of the features requires the playlist to be generated so a user can define the order in which items playout (Digital Signage application) Defining the order is done, I then need to generate an XML file from the playlist.
I can generate this file by reading the directory and stripping out the required tags from each file in the directory using the following code
//read in files
$arr_filename = cms_main::readdir_ext('../../data/');
//parse files for data & load into arrays
$i = $z = 0 ;
if(isset($arr_filename) && !empty($arr_filename) && $arr_filename != ''){
foreach($arr_filename as $key => $value){
$menu_xml = new xmlparser('../../data/'.$value,'r');
$arr_id[$z] = $menu_xml->read_section('menu', 'id');
$arr_subid[$z] = $menu_xml->read_section('menu', 'subid');
$arr_link[$z] = $menu_xml->read_section('menu', 'link');
$z++ ;
}
}
// Write new xml file
$xmluser = new xmlparser('../../data/cms_order/play.xml','w');
$xmluser->xml_declaration();
$xmluser->xml_section('playorder');
$i = $z = 0;
foreach($arr_filename as $key => $value){
$xmluser->write_value('id', $arr_id[$z]);
$xmluser->write_value('subid', $arr_subid[$z]);
$xmluser->write_value('link', $arr_filename[$z]);
$z++ ;
}
$xmluser->xml_section_buffer();
$xmluser->xml_section_end('playorder');
$xmluser->_xmlparser();
which generates the following XML
<?xml version="1.0" encoding="utf-8"?>
<playorder>
<id>2</id>
<subid>-</subid>
<link>00001.xml</link>
<id>1</id>
<subid>3</subid>
<link>8b1bb.xml</link>
<id>1</id>
<subid>2</subid>
<link>476ff.xml</link>
<id>1</id>
<subid>4</subid>
<link>b95d9.xml</link>
<id>0</id>
<subid>-</subid>
<link>67380.xml</link>
<id>1</id>
<subid>-</subid>
<link>94c6a.xml</link>
</playorder>
However I want to generate the following xml
<?xml version="1.0" encoding="utf-8"?>
<playorder>
<id>2</id>
<file>
<subid>-</subid>
<link>00001.xml</link>
<id>1</id>
</file>
<file>
<subid>3</subid>
<link>8b1bb.xml</link>
<id>1</id>
</file>
<file>
<subid>2</subid>
<link>476ff.xml</link>
<id>1</id>
</file>
<file>
<subid>4</subid>
<link>b95d9.xml</link>
<id>0</id>
</file>
<file>
<subid>-</subid>
<link>67380.xml</link>
<id>1</id>
</file>
<file>
<subid>-</subid>
<link>94c6a.xml</link>
<id>1</id>
</file>
</playorder>
I have tried the following
// Write new xml file
$xmluser = new xmlparser('../../data/cms_order/play.xml','w');
$xmluser->xml_declaration();
$xmluser->xml_section('playorder');
$i = $z = 0;
foreach($arr_filename as $key => $value){
$xmluser->xml_section('file');
$xmluser->write_value('id', $arr_id[$z]);
$xmluser->write_value('subid', $arr_subid[$z]);
$xmluser->write_value('link', $arr_filename[$z]);
$xmluser->xml_section_end('file');
$z++ ;
}
$xmluser->xml_section_buffer();
$xmluser->xml_section_end('playorder');
$xmluser->_xmlparser();
But all that gives me is :
<?xml version="1.0" encoding="utf-8"?>
<playorder>
<id>2</id>
<file>
</file>
<file>
</file>
<file>
</file>
<file>
</file>
<file>
</file>
<file>
</file>
<subid>-</subid>
<link>00001.xml</link>
<id>1</id>
<subid>3</subid>
<link>8b1bb.xml</link>
<id>1</id>
<subid>2</subid>
<link>476ff.xml</link>
<id>1</id>
<subid>2</subid>
<link>476ff.xml</link>
<id>1</id>
<subid>4</subid>
<link>b95d9.xml</link>
<id>0</id>
<subid>-</subid>
<link>67380.xml</link>
<id>1</id>
<subid>-</subid>
<link>94c6a.xml</link>
<id>1</id>
</playorder>
Any and all assistance would be greatly helpful
Perception