|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-01-31 16:06 UTC] galg at sphera dot com
Description:
------------
When I've used the following code on php 4.3.8:
The <![CDATA[ ]> section was returned as XML_CDATA_SECTION_NODE (value 4).
When i am running the same code on 4.3.10 its returned as XML_TEXT_NODE (value 3).
Reproduce code:
---------------
<?php
$sXML = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<XML_DOC>
<![CDATA[ something inside the CDATA. ]]>
</XML_DOC>
XML;
print_r(domxml_xmltree($sXML));
?>
Expected result:
----------------
php 4.3.8 response:
=======================
domdocument Object
(
[name] => #document
[url] =>
[version] => 1.0
[encoding] => UTF-8
[standalone] => -1
[type] => 9
[compression] => -1
[charset] => 1
[0] => 4
[1] => 138008952
[children] => Array
(
[0] => domelement Object
(
[type] => 1
[tagname] => XML_DOC
[0] => 5
[1] => 138009088
[children] => Array
(
[0] => domtext Object
(
[type] => 3
[name] => #text
[content] =>
[0] => 6
[1] => 138009160
)
[1] => domcdata Object
(
[type] => 4
[content] => something inside the CDATA.
[0] => 7
[1] => 138009320
)
[2] => domtext Object
(
[type] => 3
[name] => #text
[content] =>
[0] => 8
[1] => 138009416
)
)
)
)
)
Actual result:
--------------
php 4.3.10 response:
===========================
domdocument Object
(
[name] => #document
[url] =>
[version] => 1.0
[encoding] => UTF-8
[standalone] => -1
[type] => 9
[compression] => -1
[charset] => 1
[0] => 4
[1] => 138267176
[children] => Array
(
[0] => domelement Object
(
[type] => 1
[tagname] => XML_DOC
[0] => 5
[1] => 138267304
[children] => Array
(
[0] => domtext Object
(
[type] => 3
[name] => #text
[content] =>
something inside the CDATA.
[0] => 6
[1] => 138258296
)
)
)
)
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 06:00:01 2025 UTC |
It's seems to be a problem with the integration of PHP 4.3.x and libxml2 ver 2.6.x. I've tested the following php5 script on PHP 5.0.2 compiled with libxml2-2.6.11 and it worked as expected: <?php $sXML = <<<XML <?xml version="1.0" encoding="UTF-8"?> <XML_DOC> <![CDATA[ something inside the CDATA. ]]> </XML_DOC> XML; $objXML = new DOMDocument; $objXML->loadXML($sXML); foreach ($objXML->documentElement->childNodes as $child) { echo "Type: " . $child->nodeType . "\t | \t"; echo "Name: " . $child->nodeName; echo "\n"; } ?> The php5 script returns good result: the CDATA section with type 4. Could it be that the problem is an API change in the libxml2 version 2.6.x which wasn't updated in version 4.3.x of php ? The result of the script on my environment is: Type: 3 | Name: #text Type: 4 | Name: #cdata-section Type: 3 | Name: #text Regards, Gal