Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking to auto pull an xml file from an offsite url and merge it into a sqlite db every two hours. The server is lamp. (If it is too difficult to do for sqlite, then merging the xml into a mysql table would also be fine.)

xml:

<entries>
  <entry>
    <name>John Smith</name>
    <age>20</age>
    <gender>male</gender>
  </entry>
</entries>
share|improve this question
up vote 0 down vote accepted
<?php

$file = $argv[1];
if(!$file)
    exit(1);

$data = simplexml_load_file($file);
foreach ($data as $entry){
    foreach($entry as $k=>$v){
       // change this to insert into the db ...
       echo $k . "=" . $v . "\n";
    }
}

# cron job php -q /script.php file.xml
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.