php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35943 DOMNode->nodeValue expects xml instead of simple string
Submitted: 2006-01-09 14:05 UTC Modified: 2006-01-09 15:45 UTC
From: php at jesperkristensen dot dk Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.1.1 OS: Windows XP
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
5 + 14 = ?
Subscribe to this entry?

 
 [2006-01-09 14:05 UTC] php at jesperkristensen dot dk
Description:
------------
DOMNode->nodeValue expects an xml-string. If a string containing an &-character in inputet, only the string be fore that character will be saved. If the string containg a xml entity, the &-character wille not be substituted with its entity but simply be written into the file. This thing worked as expected in PHP 5.0.x

Reproduce code:
---------------
// In the example $myNode a DOMNode object, created from the following piece of xml: <node></node>

$myNode->nodeValue = "Me & You";
// Actual xml file: <node>Me </node>
// Expected xml file: <node>Me &amp; You</node>

$myNode->nodeValue ="Me &amp; You";
// Actual xml file: <node>Me &amp; You</node>
// Expected xml file: <node>Me &amp;amp; You</node>

$val = $myNode->nodeValue;
// Works as expected

$myNode->nodeValue = $myNode->nodeValue;
// This will change the content of <node>, if it contains "&"


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-09 15:45 UTC] rrichards@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

It has always worked this way using a DOMElement node (double checked 5.0.2 thru 5.1.2RC2). Only way to get your expected results is when using the actual DOMText node.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC