php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67476 empty node is filled with sibling
Submitted: 2014-06-19 11:38 UTC Modified: 2014-06-20 07:29 UTC
From: info at gmwconsult dot nl Assigned:
Status: Closed Package: DOM XML related
PHP Version: 5.4Git-2014-06-19 (snap) OS: windows
Private report: No CVE-ID: None
 [2014-06-19 11:38 UTC] info at gmwconsult dot nl
Description:
------------
if I load a snippet of html with loadXML() and subsequently echo the contents, the first empty node is filled with the next node. This does not happen if the first node contains   or another empty node.
So the result will be:
<div>
    <nav id="filter" >
        <section id="portfolio_container">
        	<ul id="stage">
            </ul>
        </section>
    </nav>
</div>

php 5.4.19 that comes with xampp running on windows

Test script:
---------------
$html = '<div>
        <nav id="filter" />
        <section id="portfolio_container">
        	<ul id="stage">
            </ul>
        </section>
		</div>';
$doc = new DOMDocument('1.0','utf8');
$doc->loadXML($html);
echo"<pre>";
print_r($doc->saveXML());
echo"</pre>";
die();


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-06-19 18:41 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2014-06-19 18:41 UTC] requinix@php.net
Works for me. http://3v4l.org/tEfIm
Also tried on Windows with 5.5.13, 5.4.29, and 5.3.28, and the 5.5.11 that's bundled with XAMPP 1.8.3-4.

To be sure, the test script you provided is exactly what you're using? Try copying it from here and running that.
 [2014-06-20 07:29 UTC] info at gmwconsult dot nl
-Status: Feedback +Status: Closed
 [2014-06-20 07:29 UTC] info at gmwconsult dot nl
As it turns out, this is actually a browser interpretation problem. IE displays the html as expected, but Chrome and FF shift the second node into the first. Thank you for your effort.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 16:01:29 2024 UTC