Hi!

I'm trying to create a html file which is generated from a xml source file which is being updated by a third party. This file is available online, and I need my html\php file to get the data from the xml file and generate a new file everytime the page loads. anothere acceptable option is to cache it and only refresh it every hour or so.

I'm able to create a html file which uses a local copy of the xml file to publish the correct data amount, but not to do this automatically with the updating version.

Any tips would be so much appreciated =)

    Depending on your server settings, you can use [man]file_get_contentsman to grab a file by URL. If allow_url_fopen is not turned on, then you would instead have to use another method, such as the [man]cURL[/man] functions. You could then save the retrieved string as a file (e.g. [man]file_put_contents/man) and operate on it as you already do with a local file. You could then use that saved file as your cache (or save the HTML as a cache file to further reduce processing) and then on each request, compare the current [man]time/man to the [man]filemtime/man for the cache file to determine if you can just use the cache, or else re-request the XML data.

      Write a Reply...