I am getting a fatal error "Fatal error: Call to a member function setStopTime() on a non-object in C:\wamp\ on line 39"
Line 39 is $m->setStopTime ( $attributes->time );
Line 40 is $m->setStartTime ( $startTime );
Can anyone help me understand this. The start and stop times are not objects but string values that I am assigning to setStartTime and setStopTime.
Am I trying to convert it to an object in order to get past the fatal error (if so, how) or am I violating some coding rule?
Line 39 is $m->setStopTime ( $attributes->time );
Line 40 is $m->setStartTime ( $startTime );
Can anyone help me understand this. The start and stop times are not objects but string values that I am assigning to setStartTime and setStopTime.
Am I trying to convert it to an object in order to get past the fatal error (if so, how) or am I violating some coding rule?
Code:
<?php
class FindXML extends ReadXML{
public $path;
public $rootFolder;
public $files = array ();
public function __construct(){
include_once('ReadXML.php');
}
public function setRootDirectory($dirPath){
$this->rootFolder = $dirPath;
}
public function loadXMLtoDatabase() {
(array) $arrDirList = ReadXML::scanFilesFolders($this->rootFolder);
$a = new ArrayObject ($arrDirList , ArrayObject::STD_PROP_LIST );
foreach ( $a as $path ) {
if (is_file ( $path )) {
if (strpos ( "$path", "xml" )) {
echo $path . "<br />";
try {
// code here
$s = simplexml_load_file ((string) $path, 'SimpleXMLElement', LIBXML_NOCDATA );
echo '<pre>';
} catch ( Exception $e ) {
echo $e->getMessage ();
}
foreach ( $s->header as $header ) :
foreach ( $s->event as $key => $event ) :
$attributes = $event->attributes ();
if ($attributes->type == 'system') :
if (strpos ( $event->text, 'Start Cap' ) !== false) :
$startTime = $attributes->time;
$asfFileName = $event->text;
elseif (strpos ( $event->text, 'Stop Cap' ) !== false) :
$m->setStopTime ( $attributes->time );
$m->setStartTime ( $startTime );
$startTime = null;
$m->save ();
endif;
elseif ($attributes->type == 'case') :
$m = new ReadXML();
$m->load ( $m->merge ( $event->case, $header ) );
endif;
endforeach
;
echo print_r ( $m->merge ( $event->case, $header ) );
endforeach
;
}
}
}
}
}