|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-07-11 22:14 UTC] stuart at horuskol dot net
Description: ------------ --- From manual page: http://www.php.net/domdocument.load%23Errors/Exceptions --- The manual page reports that this method returns false on failure - however, testing this function has resulted in exceptions being thrown instead. Can the manual be updated to reflect this? Test script: --------------- Example XML files: http://horuskol.net/media/php/map-not-xml.xml http://horuskol.net/media/php/map-malformed-xml.xml <?php $dom = new DOMDocument(); try { if (!$dom->load('not-a-file')) { throw new Exception('Error loading source file'); } } catch (Exception $e) { echo $e->getMessage(); } try { if (!$dom->load('map-not-xml.xml')) { throw new Exception('Error loading source file'); } } catch (Exception $e) { echo $e->getMessage(); } try { if (!$dom->load('map-malformed-xml.xml')) { throw new Exception('Error loading source file'); } } catch (Exception $e) { echo $e->getMessage(); } Expected result: ---------------- Error loading source file Error loading source file Error loading source file Actual result: -------------- DOMDocument::load(): I/O warning : failed to load external entity "not-a-file" DOMDocument::load(): Start tag expected, '<' not found in map-not-xml.xml, line: 1 DOMDocument::load(): Couldn't find end of Start Tag malformed line 2 in map-malformed-xml.xml, line: 2 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 04:00:02 2025 UTC |
I used the below code and the file is in uploads folder. $doc = new DOMDocument(); $doc->load("uploads/p25661072.xml"); I got this warning below. Please let me know how to solve this. "Warning: DOMDocument::load() [domdocument.load]: I/O warning : failed to load external entity "file:///C:/Program%20Files/Apache%20Software%20Foundation/Apache2.2/htdocs/ConugamSMS/includes/uploads/p25661072.xml" in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\ConugamSMS\includes\surveytaking.php on line 74"