php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42421 can not currently modify cdata node
Submitted: 2007-08-25 07:19 UTC Modified: 2007-08-27 10:31 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: hejunbin at yahoo dot com dot cn Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.2.3 OS: windows 2003
Private report: No CVE-ID: None
 [2007-08-25 07:19 UTC] hejunbin at yahoo dot com dot cn
Description:
------------
the simplexmlelement can not currently modify cdata node


Reproduce code:
---------------
<?php
$xml_string = <<<EOD
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<a>
 <b>b</b>
 <c><![CDATA[c]]></c>
</a>
EOD;

$xml = simplexml_load_string($xml_string);
$a = $xml->xpath('//a');
$a[0]-> b = B;
$a[0]-> c = C;

echo $xml-> saveXML();
?>

<a>
 <b>B</b>
 <c>C</c>
</a>

Expected result:
----------------
<?php
$xml_string = <<<EOD
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<a>
 <b>b</b>
 <c><![CDATA[c]]></c>
</a>
EOD;

$xml = simplexml_load_string($xml_string);
$a = $xml->xpath('//a');
$a[0]-> b = B;
$a[0]-> c = C;

echo $xml-> saveXML();
?>

<a>
 <b>B</b>
 <c><![CDATA[C]]</c>
</a>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-25 07:54 UTC] chregu@php.net
There's no difference betweeen <![CDATA[C]]> and just C from an XML 
point of view... It's the same, just differently serialized



 [2007-08-26 06:43 UTC] hejunbin at yahoo dot com dot cn
<![CDATA[C]]> and C

i think it's different!

that's why xml document have CDATA node.

so i think it is a problem.

hope some one can resolve it.
 [2007-08-27 10:31 UTC] jani@php.net
What chregu@php.net said. Expected behaviour -> bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 24 02:01:30 2024 UTC