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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: hejunbin at yahoo dot com dot cn
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Thu Dec 26 14:01:30 2024 UTC