Php – XML API to PHP! New developer, no idea how to do this


Simple question, I should think. Unfortunately, I couldn't figure out how to get it working.

I have an xml data sheet that looks like this:

        <campaign_name>Tesco vs Argos - Submit (UK)</campaign_name>
        <date>2012-03-24 07:19:07</date>

I should add that this XML sheet is not hosting on my servers, but is dynamically updated as I get a new lead, by my network. Feel free to ask me more questions if needed.

MY QUESTION IS: How can I write a code that reads the XML page, and uploads, for each , the date, the IP, and the campaign_name to a mySQL table.


Best Solution


           if( $xml = simplexml_load_file("the_url_of_xml"))
              foreach($xml->leads->leadDetails as $detail) 
                $camp_id = $detail->campaign_id;
                $camp_name = $detail->campaign_name;
                $sql = "INSERT INTO myTable (id,name) VALUES ('$camp_id','$camp_name')";//AND so on