note 76372 added to function.dom-domdocument-xinclude
| From: | nicolas_rainardNOSPAM at yahoo dot fr | Date: | Thu, 12 Jul 2007 11:56:14 +0000 |
| Subject: | note 76372 added to function.dom-domdocument-xinclude | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128407@lists.php.net to get a copy of this message | ||
If you use the loadXML() method instead of the load() one (let's say, to process the XML string
before loading and parsing it), you will have problems with xinclude(), because the parser will not
know where to find the files to include.
Using chdir() before xinclude() will not help.
The solution is to set the documentURI property of the DOMDocument object accordingly to it's
original filename, and everything will work fine !
<?php
$xml = file_get_contents($file);
$xml = do_something_with($xml);
$doc = new DOMDocument;
$doc->documentURI = $file;
$doc->loadXML($xml);
$doc->xinclude();
?>
----
Server IP: 69.147.83.197
Probable Submitter: 90.31.43.163
----
Manual Page -- http://www.php.net/manual/en/function.dom-domdocument-xinclude.php
Edit -- https://master.php.net/note/edit/76372
Del: integrated -- https://master.php.net/note/delete/76372/integrated
Del: useless -- https://master.php.net/note/delete/76372/useless
Del: bad code -- https://master.php.net/note/delete/76372/bad+code
Del: spam -- https://master.php.net/note/delete/76372/spam
Del: non-english -- https://master.php.net/note/delete/76372/non-english
Del: in docs -- https://master.php.net/note/delete/76372/in+docs
Del: other reasons-- https://master.php.net/note/delete/76372
Reject -- https://master.php.net/note/reject/76372
Search -- https://master.php.net/manage/user-notes.php