XML Feed - Loading Time Very Slow

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
clavigne
Forum Newbie
Posts: 7
Joined: Tue May 11, 2010 10:53 am

XML Feed - Loading Time Very Slow

Post by clavigne »

Hi all...

On behalf of a client, I'm trying to post an XML feed of real estate listings on her site. This feed is set in stone and to make matters worse, is full of things that invalidate it such as & symbols. It has around 750 entries on any given day.

I thought I had found a way around the problems with the feed by using curl() to get the feed's contents, then using str_replace to get rid of the ampersands. In order to sort the feed so that it listed homes in price order, I then converted the string back into XML through a function found on PHP.net. Finally, I converted the XML into an array so that I could play around with sorting it.

All of this made for a page that took a long time to load--30-40 seconds--although the original feed takes around 20-30 seconds to load anyway if all you do is curl() it.

Is there a more straightforward way of doing this? I need to

a) get the XML feed
b) remove the characters that invalidate the XML
c) sort the feed
d) show only 10 items from the feed at a time

I'm not allowed to share the link to the feed as it comes with a subscription fee.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: XML Feed - Loading Time Very Slow

Post by yacahuma »

you did not mention how often the list changes. If is daily, you can just process it once(inside a cron) and create an html or whatever you want the output to be.
clavigne
Forum Newbie
Posts: 7
Joined: Tue May 11, 2010 10:53 am

Re: XML Feed - Loading Time Very Slow

Post by clavigne »

Unfortunately, it's updated periodically throughout the day. And part of the rules of using the feed is that I'm not allowed to cache it or save it anywhere before using it. It must come directly from the feed.

That said, what if I had the cron run hourly?
Post Reply