Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

simplexml_load_file not working with date as file name

$
0
0

hey guys, having issues trying to get xml to load a file that has date as it's file name.  I have a script that creates an xml.

<?php

$companyName = ($_GET['VcomName']);
$visitDate        = ($_GET['Vdate']);
$visitors    = ($_GET['Vname']);

//$VcomName = 'test';
$vdoc = new DOMDocument('1.0');
$vdoc->formatOutPut = true;

$root = $vdoc->createElement('VisitorList');
$root = $vdoc->appendChild($root);

$company = $vdoc->createElement('CompanyName');
$company = $root->appendChild($company);

$ctext = $vdoc->createTextNode($companyName);
$ctext = $company->appendChild($ctext);

$visitor = $vdoc->createElement('Visitors');
$visitor = $root->appendChild($visitor);

$vtext = $vdoc->createTextNode($visitors);
$vtext = $visitor->appendChild($vtext);

$ddate = $vdoc->createElement('VisitDate');
$ddate = $root->appendChild($ddate);

$dtext = $vdoc->createTextNode($visitDate);
$dtext = $ddate->appendChild($dtext);

echo $vdoc->save($visitDate. ".xml") . "\n";

?>

It creates the file with the date submited in a form for a visitor board.

 

Im trying to open the file so that i can print out the visitor names and the company that is visiting.

<?php
libxml_use_internal_errors(true);

 $fileD=date('Y-m-d');
 
 echo "$fileD \n";
 
 $file = "/inc/$fileD.xml";

 include "/inc/2013-08-11.xml";
 
 
 $file = preg_replace('/[\s]+/',' ',$file);
 
    if(file_exists($file)) {
        $fxml = simplexml_load_file($file);
    
	        print_r($fxml);
    } else {
	    exit("The file $file Does not exist \n");
	}
?>

In this i have done some testing ... the include will work but the simplexml fails to find the file. All it gives me is the exit printout on the screen.

 

Im not sure why this is not working.  there are no errors besides unable to find the file.


Viewing all articles
Browse latest Browse all 13200

Trending Articles