#34917 [NEW]: saveXML(documentFragment) produces an "empty" <> tag
| From: | bart at mediawave dot nl | Date: | Wed, 19 Oct 2005 13:51:57 +0000 |
| Subject: | #34917 [NEW]: saveXML(documentFragment) produces an "empty" <> tag | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-86745@lists.php.net to get a copy of this message | ||
From: bart at mediawave dot nl
Operating system: Fedora Core 4
PHP version: 5.0.5
PHP Bug Type: DOM XML related
Bug description: saveXML(documentFragment) produces an "empty" <> tag
Description:
------------
When using saveXML(node) with a documentFragment an "empty tag" like <> is
appended at the beginning of the string. Strangely this occurs with XHTML
doctypes but not with XML documents without a doctype. I haven't tested it
with other doctypes. It looks like it tries to output the documentfragment
as a tag.
Reproduce code:
---------------
<?php
$xml = '<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
[]>
<div>
<h1>The quick brown fox jumps over the lazy dog</h1>
<p>And he also jumped over a cow </p>
</div> ';
$doc = new DOMDocument();
$doc->loadXML($xml);
$div = $doc->getElementsByTagName('div')->item(0);
$frag = $doc->createDocumentFragment();
while ($childNode = $div->firstChild) {
$frag->appendChild($childNode);
}
echo $doc->saveXML($frag);
?>
Expected result:
----------------
The quick brown fox jumps over the lazy dog
And he also jumped over a cow
Actual result:
--------------
<>
The quick brown fox jumps over the lazy dog
And he also jumped over a cow
--
Edit bug report at http://bugs.php.net/?id=34917&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34917&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34917&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34917&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34917&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34917&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34917&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34917&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34917&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34917&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34917&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=34917&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=34917&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34917&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34917&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34917&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34917&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34917&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34917&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34917&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34917&r=mysqlcfg