XML Feed

4 posts by 3 authors in: Forums > CMS Builder
Last Post: November 25, 2015   (RSS)

Is there a way to generate an XML feed from my website to another company's website?

Thanks in advance.

By Daryl - November 23, 2015

Hi Carole,

The other website's php page can use file_get_contents() function to get your website's XML contents and dump it.
For example (code for other website's page):

$yourWebsitesXmlPageContents = file_get_contents("http://yourwebsite.com/xml.php");
echo $yourWebsitesXmlPageContents;

Let me know if this is the solution you're looking for.

Thanks,

Daryl Maximo
PHP Programmer - interactivetools.com

By ross - November 25, 2015

Hi Carole

With your current example, the other site would need to know the individual URL's and have a command to load each one of them individually.  If your pages are numbered sequentially, though, the other site could use a "for" loop like this:

for ($i = 1; $i <= 10; $i++) {
    $yourWebsitesXmlPageContents = file_get_contents("http://yourwebsite.com/xml.php?$i");
    echo $yourWebsitesXmlPageContents;
}

Does that seem like it could work?

Another option would be to provide the other site with a single feed and after they use code like Daryl's to get the contents, they can parse it out themselves.

Ross

for ($i = 1; $i <= 10; $i++) {
    echo $i;
}

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/