Accessing XML documents in the server from a PHP script

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
rsouthon
Forum Newbie
Posts: 5
Joined: Tue Jul 11, 2006 12:00 pm
Location: Toronto

Accessing XML documents in the server from a PHP script

Post by rsouthon »

Hey,

I'm kinda new to PHP so I'm not even sure it's the right tool for the job but here goes:

I have a few reference documents that are used throughout my site. They are fairly large XML & XSLT documents that need to be used quite often by multiple php and javascript functions. How do I store these documents in the server memory so that they don't need to be reloaded each time a function uses them?

The way I'm doing it now is sending a GET HTTP header to give me the file and then using DOM to parse it and get my info - kindof AJAX-like. But the GET is slow and I want to avoid it.

Any ideas? Am i going about this the wrong way? Can PHP solve my problems?

Thanks so much!
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

PHP can handle XML parsing fairly effectively and efficiently if done right. There are some native XML functions to PHP, but most fokls use them to make their own XML readers. In fact, I have just taken a script I found on a tutorial at Sitepoint and used that as a basis for a multi-input XML/RSS reader. So yeah, PHP can do it and it can do it well if done right.
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post by jamiel »

How do I store these documents in the server memory so that they don't need to be reloaded each time a function uses them?
Look at memcache and the PHP Memcache functions : http://php.net/memcache
Post Reply