![]() |
Creating a XML File
FYI - have created a script to export data base to XML file
Hope this can be helpful to someone else. :banana: <?php // example of connection to a database $hostname ="remotemysqlhost"; $username ="kenn3_caldlma"; $password ="paswrd"; $dbName = "kenn3_dlmcal"; $conn = mysql_connect($hostname,$username,$password); mysql_select_db($dbName) or die("Could Not Connect To Database"); // example of querying your table $query = "select id, startDate, endDate, title, descr, category from epc_calendar"; // example of getting results from query $result = mysql_query($query,$conn); if($result) { // if query ran successfully // loop over results //open file to write to $file_handle = fopen('events.xml','w'); // i normal remove this this line $xmlPacket = "<?xml version='1.0'?>\n"; //---- $xmlPacket .="<newsblock>\n"; while($row = mysql_fetch_array($result,MYSQL_ASSOC)){ // build xml to a variable $xmlPacket .= "\n<news> <active>YES</active> <id>".$row['id']."</id> <startdate>".$row['startDate']."</startdate> <enddate>".$row['endDate']."</enddate> <title>".$row['title']."</title> <descr>".$row['descr']."</descr> <category>".$row['category']."</category> </news> \n"; } $xmlPacket .= '</newsblock>'; } else{ // you probably want to remove this when you are putting this code live. die('query failed' . mysql_error()); // you can replace it with this: // which will just build an empty packet rather than killing the process $xmlPacket = "<?xml version='1.0'?><calendar></calendar>"; } // write var to file fwrite($file_handle,$xmlPacket); fclose($file_handle); die('Done....'); ?> |
Thanks for sharing. :)
[Makes into a Sticky] |
How can you turn this around to import?
We create a word document with calendar events, then manually put them one by one into our online calendar. How can you make our word document into an xml file to upload into PHP calendar?
|
I have used this script but get the following error:
XML Parsing Error: no element found Location: http://www.??????.co.uk/members/calendar/events.xml Line Number 5, Column 1: any suggestions ? rgds jerry |
Quote:
I have aquestion myself though... I have ZERO experience with .ics(iCal) filetypes and am looking for a method of querying the DB as it was successfully accomplished by the above script(thanks by the way) and parsing that info into a useable .ics file stored on my server which is the external feed to the (another) Calendar I also use. Anyone have any ideas? Although it would be very nice, I'm not overly concerned with a 2-way sync, but instead just getting the feed to my (another) Calendar, in turn having it transmitted(auto synced which is already accomplished) to my BlackBerry. |
| All times are GMT -4. The time now is 09:16 AM. |
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright 2009 NashTech, Inc.