note 119775 added to class.domdocument
| From: | biker dot mike at gmx dot com | Date: | Mon, 22 Aug 2016 13:36:34 +0000 |
| Subject: | note 119775 added to class.domdocument | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206365@lists.php.net to get a copy of this message | ||
Look out for the following gotcha when loading XML from a string:
<?php
$doc = new \DOMDocument;
$doc->documentURI = $myXmlFilename;
$doc->loadXML($myXmlString);
?>
documentURI is now set to the value of $myXmlFilename, right?
Wrong!
It's set to the current working directory. If you want to manually set documentURI to
something other than the CWD, do so AFTER the call to loadXML().
E.g.:
<?php
$doc = new \DOMDocument;
$doc->loadXML($myXmlString);
$doc->documentURI = $myXmlFilename;
?>
documentURI really is now set to the value of $myXmlFilename.
----
Server IP: 91.199.167.223
Probable Submitter: 86.190.139.157
----
Manual Page -- http://php.net/manual/en/class.domdocument.php
Edit -- https://master.php.net/note/edit/119775
Del: integrated -- https://master.php.net/note/delete/119775/integrated
Del: useless -- https://master.php.net/note/delete/119775/useless
Del: bad code -- https://master.php.net/note/delete/119775/bad+code
Del: spam -- https://master.php.net/note/delete/119775/spam
Del: non-english -- https://master.php.net/note/delete/119775/non-english
Del: in docs -- https://master.php.net/note/delete/119775/in+docs
Del: other reasons-- https://master.php.net/note/delete/119775
Reject -- https://master.php.net/note/reject/119775
Search -- https://master.php.net/manage/user-notes.php