|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-10-19 15:17 UTC] ndb1974 at yahoo dot co dot uk
Description:
------------
php 5.0.4 contains libXML 2.6.11
This works appears to work correctly with text string variables
php 5.05 contains libXML 2.6.9 (not sure why it contains an older libXML)
This version combination contains a fault where XML string content containing apostrophes (') is corrupted when reading or writing XML variables using simpleXML. The XML functionality tries to escape the apostrophe with several backspaces, corrupting the string when it is processed. But this does NOT happen with libXML 2.6.11.
Reproduce code:
---------------
Store an XML doc like:
<testdoc>
<testvar>Something's not right with ' chars</testvar>
</testdoc>
Open it with a php script like:
$dom = new DomDocument;
$xml = simplexml_load_file($XMLTestDoc);
$XMLpath = $xml -> xpath("/testdoc");
$teststring = $XMLpath[0] -> testvar;
echo ($teststring);
Expected result:
----------------
Should see same string again.
Actual result:
--------------
String is displayed like:
Something\\\\'s not right with \\\' chars
(i.e. corrupted with backslashes).
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 13:00:01 2025 UTC |
But is it libXML that the following PHP5 code relies on $xml = simplexml_load_file($XMLTestDoc); $XMLpath = $xml -> xpath("/testdoc"); $teststring = $XMLpath[0] -> testvar; ????