Results 1 to 5 of 5

Thread: Prevent the error loading XML

  1. #1
    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:
    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?

  2. #2
    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.

  3. #3
    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.

  4. #4
    Join Date
    May 2008
    Posts
    2,302

    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)?

  5. #5
    Join Date
    May 2008
    Posts
    2,015

    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

Similar Threads

  1. Replies: 4
    Last Post: 03-09-2011, 12:00 PM
  2. Error loading gssetbasemem: error loading symbol
    By Chaya in forum Operating Systems
    Replies: 3
    Last Post: 04-08-2009, 08:23 AM
  3. How to fix Error loading C:
    By Bisujaksha in forum Operating Systems
    Replies: 3
    Last Post: 06-04-2009, 03:19 PM
  4. Replies: 3
    Last Post: 07-09-2008, 07:39 PM
  5. Error loading Run dll
    By Kevin in forum Vista Help
    Replies: 2
    Last Post: 12-06-2008, 09:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •