Hello again
I'm having another slight problem.
This time I think its becase of my includes files. The xml files that I am trying to select are sitting in a seperate folder to my php page.
This first bit of code is called Aquarius.php and this file sits in the same folder (newsfeed) as my xml files. Lines 3 - 19 check the filename of an xml page to make sure its the right one (thanks again bpat!). The rest of the code parses and prints out the xml :
<?php
$latest = 0;
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if (substr($file,-4) == ".xml") {
if(eregi("Aquarius", $file)) // See if Aquarius is in the filename
{
$filename_array = explode("_",$file);
if ($filename_array[count($filename_array)-2] > $latest)
{
$latest = $filename_array[count($filename_array)-2];
$xml_file = $file;
}
}
}
}
closedir($handle);
}
// read xml file into string
$text = file_get_contents($xml_file) or die("read file failed");
// parse the xml into structure
$p = xml_parser_create();
xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);
xml_parse_into_struct($p, $text, $vals, $index);
xml_parser_free($p);
// read data of interest from structure into array:
for($i=0; $i<$index['content.item'][1]; $i++)
{
foreach(array('title', 'Para') as $key)
{
$data[$i][$key] = $vals[$index[$key][$i]]['value'];
}
}
foreach($data as $val)
{
echo "<p class='content'><h3>" . $val['title'] . "</h2></p>";
echo "<p class='content'>" . $val['Para'] . "</p>";
}
?>
Now I need to put the above into another page using includes files. The code below sits outside the newsfeed folder (where my xml is stored):
<?php
$starsign = $_GET['starsign'];
$Aquarius = "Aquarius";
if ($starsign == $Aquarius){
include("newsfeed/Aquarius.php");
}
?>
So when this code is run, it gives me the error message from the Aquarius.php
page "read file failed" which indicates that the xml file is not being selected.
Anybody see what I'm doing wrong here? is there something wrong with my paths?
Thanks!
John