Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Prevent the error loading XML

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 02-12-2009
Member
 
Join Date: Nov 2009
Posts: 47
Prevent the error loading XML
  

I'm coding a little script that retrieves information stored on an xml on a remote server. The trouble is when I load the XML in this way:
Code:
$xml = new SimpleXMLElement("http://www.xxx.com/address/of/xml.xml", NULL, TRUE );
Well I happen to have the following error because of too many connected at the same time:
Quote:
Warning: SimpleXMLElement::__construct(http://www.xxx.com/address/of/xml.xml) [simplexmlelement.--construct]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in C:\Program Files\EasyPHP5.3.0\www\project\resources\xml.php on line 43
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: I/O warning : failed to load external entity "http://www.xxx.com/address/of/xml.xml" in C:\Program Files\EasyPHP5.3.0\www\project\resources\xml.php on line 43
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\Program Files\EasyPHP5.3.0\www\project\resources\xml.php:43 Stack trace: #0 C:\Program Files\EasyPHP5.3.0\www\project\resources\xmlr.php(43): SimpleXMLElement->__construct('http://www.xxx.com/address/of/xml.xml', 0, true) #1 {main} thrown in C:\Program Files\EasyPHP5.3.0\www\project\resources\xml.php on line 43
How can I ensure that the XML will be reloaded until there is no error and continue the execution of my script?

Reply With Quote
  #2  
Old 02-12-2009
Member
 
Join Date: Nov 2005
Posts: 1,323
Re: Prevent the error loading XML

Are you sure it's because of too many online? Otherwise you can go through the function http://www.php.net/manual/en/functio...-load-file.php. It is generally the same as what you want, except that it returns either a SimpleXMLElement or false. So a loop should get what you want. But stinks the risk of infinite loop your thing.
Reply With Quote
  #3  
Old 02-12-2009
Member
 
Join Date: Nov 2009
Posts: 47
Re: Prevent the error loading XML

Thank you for this response, its exactly what I needed and it works great. Yes even I feel that the infinite loop but not the right choice. Yes there are too many people who consult the xml at the same time.
Reply With Quote
  #4  
Old 02-12-2009
Member
 
Join Date: May 2008
Posts: 2,290
Re: Prevent the error loading XML

It is not a good idea to put the xml in BD or make a counter of number of people who want to read this xml and spent a nb, copy the file (basically a mini load management)?
Reply With Quote
  #5  
Old 02-12-2009
Member
 
Join Date: May 2008
Posts: 2,007
Re: Prevent the error loading XML

Macario in your case I assume that this XML, you'll find on a server other than yours, and this XML you load each time a visitor passes. It's just as disgusting approach. You could not store it on your site, and do update every 30 minutes for example. It will avoid overloading the remote server that hosts the XML
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Prevent the error loading XML"
Thread Thread Starter Forum Replies Last Post
Getting “Error Initializing Frame Buffer Object” error at the end of Achron loading Namkar Video Games 4 03-09-2011 12:00 PM
Error loading gssetbasemem: error loading symbol Chaya Operating Systems 3 04-08-2009 08:23 AM
How to fix Error loading C: Bisujaksha Operating Systems 3 06-04-2009 03:19 PM
Help! Error Message-->> The system administrator has set policies to prevent this installation Katmandu Vista Help 3 07-09-2008 07:39 PM
Error loading Run dll Kevin Vista Help 2 12-06-2008 09:27 AM


All times are GMT +5.5. The time now is 07:11 AM.