Catch XML parsing Exceptions.

This is a discussion on "Catch XML parsing Exceptions." within the PHP Forum section. This forum, and the thread "Catch XML parsing Exceptions. are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 5th, 2008, 10:53
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Catch XML parsing Exceptions.

Okay I'm trying to create an API.
I need to it be user friendly so it can't output an errors.
I've used a try {} catch() {} in this class and purposely passed a file doesn't exist to the constructor.
I would expect $x to just return false and the script to die but I get this error:
Quote:
Warning: SimpleXMLElement::__construct() [function.SimpleXMLElement---construct]: I/O warning : failed to load external entity "settings.php" in C:\Web\XML\XMLsettingsCMS\parse.php on line 56
And this is my class and it being instantiated.
PHP: Select all

class XMLstore {
    private 
$XML;
    function 
__construct($xmlfile) {
    
$this->XML $xmlfile;
     try {
         
$this->handle = new SimpleXMLElement($this->XMLNULLtrue);
    } 
    catch(
Exception $e) {
        return 
false;
        }        

    }
}
if(!
$x = new XMLstore('settings.php')) { die("Couldn't be done"); } 
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote

Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
xml parsing ktsirig PHP Forum 1 Apr 12th, 2008 16:05
[SOLVED] simple catch the ball game ahwell Flash & Multimedia Forum 10 Jan 25th, 2008 22:58
[SOLVED] Can I catch up? 5 yrs out of WebDev... tigerw550 Starting Out 3 Dec 14th, 2007 03:06
Javascript to catch browser/plugins event le duc bao JavaScript Forum 0 May 10th, 2007 12:38
Parsing text Donny Bahama PHP Forum 6 Jun 1st, 2006 07:25


All times are GMT. The time now is 02:07.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43