Jump to content

XML not opening data


bateman

Recommended Posts

So I've tried 6 different methods of pulling the data from the xml but each time I get nothing. I KNOW it's going to be something stupidly simple, but at the moment I'm stumpped. Here is the code I'm working with, and not that it's not complete as I still need to write in the glob code to limit the results to a single date. Edit: the print is commented because I used it to show me that the xml is reading.

$date = date("Y-m-d"); 


//echo $fdate;




$glob = "./fromdb/TimesheetBackup_" . $date. "*.xml";
foreach (glob ($glob) as $result) {
echo $result;
	
		$xml = simplexml_load_file($result);
		$count = 0;
//print_r($xml);// "<br> $xml";
foreach ($xml->tasks[] as $tasks):
	$starttimeb = $tasks['startDate'];
        $starttime = substr($starttimeb, -8, -1);        
   	$endtime = $tasks->key->endDate;
        echo $starttime;
echo "<br> $endtime";
    endforeach;	

}

and a sample of the xml (end of a 48 record xml)

      <task>
         <taskId>f620bba390874d9fa41ddc4384ac0ba0</taskId>
         <projectId>7ab307cc59e84219b5e1b7b6215a7400</projectId>
         <description></description>
         <location>552 Pandora Ave, Victoria, BC V8W 1N7</location>
         <startDate>2014-01-02T13:15:00</startDate>
         <endDate>2014-01-02T16:33:00</endDate>
         <deleted>false</deleted>
         <endTime>0</endTime>
         <startTime>0</startTime>
         <lastUpdate>1388709184182</lastUpdate>
         <paid>0</paid>
         <feeling>0</feeling>
      </task>
   </tasks>
</timesheet>

I'm trying to get this to work with a xml that's created by the android app Timesheet. This is from it's auto backup system so I have no control over the output of the xml.

Link to comment
https://forums.phpfreaks.com/topic/285066-xml-not-opening-data/
Share on other sites

the glob was showing the file names, and the foreach you posted worked, now I just need to format it for my needs (the substr and such, which I've already tested).

 

Right now I have it outputing to the screen, but once it's done, it's going to be a cron update page.

 

Thank you

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.