Manhag Posted November 24, 2012 Share Posted November 24, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/271092-export-xml-to-database/ Share on other sites More sharing options...
JD* Posted November 25, 2012 Share Posted November 25, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/271092-export-xml-to-database/#findComment-1395013 Share on other sites More sharing options...
Iluvatar+ Posted November 26, 2012 Share Posted November 26, 2012 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; } Quote Link to comment https://forums.phpfreaks.com/topic/271092-export-xml-to-database/#findComment-1395108 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.