Jump to content

Export Xml To Database


Manhag

Recommended Posts

hello

to store a list in a column of a database table......is it a good idea ??

 

i want to export that xml file to database

http://www.islamicfinder.org/prayer_service.php?country=tunisia&city=qabis&state=&zipcode=&latitude=33.8833&longitude=10.1167&timezone=1.00&HanfiShafi=1&pmethod=1&fajrTwilight1=&fajrTwilight2=&ishaTwilight=0&ishaInterval=0&dhuhrInterval=1&maghribInterval=1&dayLight=0&simpleFormat=xml&monthly=1&month=

 

any help please ??

 

 

last question : reading data from xml is faster or from database ?

 

thanks :)

Link to comment
Share on other sites

I think the question is, to what end do you want to store the data? Is it for archival purposes? or is it something that is going to be added to all the time. If you're going to have different xml files for each listing, that might be fine, but you're still going to have a lot of parsing to do to get your data.

 

As for speed, here is some reading to do:

https://www.google.com/search?q=php+xml+vs+database&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

Link to comment
Share on other sites

Create an empty table with all the feilds you expect to get from you XML feed, then write some functions that can pull the XML in and strip it, loop it and store it!

 

 

// something like that

 function PrepareData($URL){

 /* Open the URL into a file */
 $ContentsFetch=file($URL);

 foreach ($ContentsFetch as $line_num => $line) {
 if (strpos($line,"<Item ")!=false) { $Contents[]= $line;}
 }

 for ($i=0;$i<count($Contents);$i++) {
 /* Strip out "<Item " and " />" from the XML */
 $Contents[$i]=substr($Contents[$i], 6+strpos($Contents[$i],"<Item "));
 $Contents[$i]=substr($Contents[$i], 0, strlen($Contents[$i])-4);
 $breakapart=explode("\"",$Contents[$i]);
 /* Extract field names and values */
 for ($x=0;$x<count($breakapart);$x++){
 if ($x % 2 == 0){
 $k=trim(str_replace("=", "", $breakapart[$x]));
 if ($k!='') { $this->Data[$i][$k]=$breakapart[$x+1]; }
 }

 }

 }

 return $this->Data;

 }

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.