Hi guys
Wondering if someone could give me a hand with another problem I'm currently having.
A little background first...
I'm trying to pick up a daily report which is in XML format via a URL. I then need to parse that data and insert it into a MYSQL table. The parsing and the inserting the data into the database works fine but I'm having trouble calling the actual file.
Here's a bit of the code:
$doc = new DOMDocument();
$doc->load('http://www.xxxxxxxxxxxxx.co.uk/xxxxxxxxxxx.aspx?AccountID=xxxxxxxxxxxxx&CampaignID=xxxxxxxxxx&FromDate=03/07/2010 00:00:00&ToDate=04/07/2010 00:00:00&type=xml');
$arrFeeds = array();
foreach ($doc->getElementsByTagName('item') as $node) {
$itemRSS = array (
'title' => $node->getElementsByTagName('transdate')->item(0)->nodeValue
);
array_push($arrFeeds, $itemRSS);
........
........
}
Doesn't seem to do anything when I run it but if I manually save the file in XML and then run the same code loading that XML file it works perfectly.
So, in my wisdom I thought that it might be a case that I can't use the URL in the code but can instead try to save the file automatically onto the server in XML format and then run the script and it should work fine.
Unfortunately no matter what I do I can't get the file to save on my server.
Here's what I have but it's probably all wrong!
$url = "http://www.xxxxxxxxxxxxx.co.uk/xxxxxxxxxxx.aspx?AccountID=xxxxxxxxxxxxx&CampaignID=xxxxxxxxxx&FromDate=03/07/2010 00:00:00&ToDate=04/07/2010 00:00:00&type=xml";
$file = fopen($url,"rb");
if($file){
$newfile = fopen("./reports/xxxx.xml", "wb");
if($newfile){
while(!feof($file)){
fwrite($newfile,fread($file,1024 * 8),1024 * 8);
}
}
}
Would anyone kindly be able to point me in the right direction?