Ok Perhaps, I am going about this the wrong way, but here is what I
have.
$string_data = array();
$data_flag = 0; //data we want printed flag ... which is everything
that is entered in switch()
$desc_flag = 0; //desc element flag
$end_flag = 0; //end element flag
$prog_flag = 0; //programme element flag
$strt_flag = 0; //start element flag
$titl_flag = 0; //title element flag
$list_flag = 0; //Programme Listing Finish
function startElement($parser, $element_name, $element_attrs)
{
global $data_flag, $desc_flag, $end_flag, $prog_flag, $strt_flag,
$titl_flag, $list_flag;
switch($element_name)
{
case "programme":
$prog_flag = 1;
$list_flag = 1;
break;
case "title":
$titl_flag = 1;
$data_flag = 1;
break;
case "desc":
$desc_flag = 1;
$data_flag = 1;
break;
case "start":
$strt_flag = 1;
$data_flag = 1;
break;
case "end":
$end_flag = 1;
$data_flag = 1;
break;
default :
$data_flag = 0;
break;
}
}
function endElement($parser, $element_name)
{
global $data_flag, $desc_flag, $end_flag, $prog_flag, $strt_flag,
$titl_flag, $list_flag, $string;
switch($element_name)
{
case "programme":
$prog_flag = 0;
$list_flag = 0;
break;
case "title":
$titl_flag = 0;
$data_flag = 0;
break;
case "desc":
$desc_flag = 0;
$data_flag = 0;
break;
case "start":
$strt_flag = 0;
$data_flag = 0;
break;
case "end":
$end_flag = 0;
$data_flag = 0;
break;
default :
$data_flag = 0;
break;
}
}
function charData($parser,$data)
{
global $data_flag, $desc_flag, $end_flag, $prog_flag, $strt_flag,
$titl_flag, $list_flag;
if ($data_flag == 1){
if ($desc_flag == 1){
$string['desc'] = "$data<br />\n";
}
if ($end_flag == 1){
$string['end'] = "$data<br />\n";
}
if ($strt_flag == 1){
$string['strt'] = "$data<br />\n";
}
if ($titl_flag == 1){
$string['titl'] = "$data<br />\n";
}
}
if ($list_flag == 1){
if (is_array ($string)){
print "{$string['strt']}";
print "{$string['end']}";
}
}
}
This is for a tv listing with the following as a sample entry
<programme>
<desc>Start your day with all the latest news, sport, business and
weather from the BBC's Breakfast team. Includes regional news at 25 and
55 minutes past each hour.</desc>
<title>Breakfast</title>
<end>0915</end>
<infourl>http://www.bbc.co.uk/cgi-perl/whatson/prog_parse.cgi?FILENAME=20050107/20050107_0600_4223_34428_195</infourl>
<start>0600</start>
</programme>
Now I would like to have this information listed as
start end
title
desc
However, as I have it now, it simply prints out as it is parsed. ie.
desc
title
end
start
Any Ideas, hints, suggestions? I would love to use XSLT for this, but
unfortunately, the client does not want to. (grumble)
TFTH
Ron Chaplin
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
T73 Software & Design
www.t73-softdesign.com
To provide custom and quality
software, designs and services,
to our customers, at an affordable rate,
with minimal delay.