php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36263 DOM XML breaks on copyright character in text node
Submitted: 2006-02-02 19:13 UTC Modified: 2006-02-02 20:56 UTC
From: thom at genx dot net Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.1.2 OS: Linux (gentoo)
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: thom at genx dot net
New email:
PHP Version: OS:

 

 [2006-02-02 19:13 UTC] thom at genx dot net
Description:
------------
When a copyright character (ascii 169) is present in a string that is added as a text node to the DOM structure, the element is always empty.  The correct behavior is to encode the character as "©".

Reproduce code:
---------------
<?php
$doc = new DOMDocument('1.0');
$t = $doc->appendChild($doc->createElement('test'));
$t->appendChild($doc->createTextNode('&' . chr(169) . '<'));

header('Content-type: text/xml');
echo $doc->saveXML();
?>


Expected result:
----------------
<?xml version="1.0"?>
<test>&amp;&copy;&lt;</test>

Actual result:
--------------
<?xml version="1.0"?>
<test></test>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-02 19:52 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

utf8 encode the character. And no it wont output &copy; thats an HTML entity.
 [2006-02-02 20:47 UTC] thom at genx dot net
Thank you.  That fixed the problem I was having.  I do apologize for having skipped over the user contributed notes, but I did try other encoding functions (just not utf8_encode()).  It is also strange that I did not get any warnings or errors as reported in the user notes (error reporting set at E_ALL).

Thanks again.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 14:01:35 2025 UTC