|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-04-27 14:24 UTC] jazzslider at gmail dot com
[2007-04-27 15:41 UTC] jazzslider at gmail dot com
[2007-04-28 21:28 UTC] rrichards@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 05:00:01 2025 UTC |
Description: ------------ When using loadXML() to fill in a DOMDocument object from a pre-existing XML string, entity references will cause the method to fail, even though there does not seem to be a way to explicitly define such entity references in the document prior to calling loadXML(), nor does it seem to be necessary to do so when creating the same document via DOMDocument methods directly. Also note: I am using PHP 5.2.0-8, and cannot upgrade to 5.2.1 since my site is on a shared server. Reproduce code: --------------- <h1>DOMDocument Entity Test</h1> <h2>Created Via DOM Methods</h2> <div> <?php $dd1 = new DOMDocument(); $dd1_root = $dd1->createElement('span', 'This is the sample span.'); $dd1_root = $dd1->appendChild($dd1_root); $dd1_nbsp = $dd1->createEntityReference('nbsp'); $dd1_nbsp = $dd1_root->appendChild($dd1_nbsp); $str = $dd1->saveXML(); echo $str; ?> </div> <h2>Loaded From String</h2> <?php $dd2 = new DOMDocument(); $dd2->loadXML($str); echo $dd2->saveXML(); ?> Expected result: ---------------- The content of the "Created Via DOM Methods" section should be identical to the content of the "Loaded From String" section. Actual result: -------------- With warnings enabled, the following message appears: "Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Entity 'nbsp' not defined in Entity, line: 2 in ..."