Jump to content

XML not opening data


bateman
Go to solution Solved by Barand,

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.

Edited by bateman
Link to comment
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.