Bug #66850 [NEW]: Different behaviors of loadXML
From: goetas at lignano dot it
Operating system: windows/linux (ubuntu)
PHP version: 5.5.10
Package: DOM XML related
Bug Type: Bug
Bug description:Different behaviors of loadXML
Description:
------------
If a XML file is not well formatted, exmample:
<div t:attr="test">foo</div>
(lacks the namespace declaration for "t" namespace)
The DOM extension works differently on windows and also some version of
ubuntu all running php 5.5.10 or 5.3.28
DOMDocument::loadXML always return true (with a warning, on all OS)
but DOMDocument::saveXML return different output on different OS
Windows:
DOM/XML API Version:20031129, libxml: 2.9.0
Linux:
DOM/XML API Version20031129, libxml: 2.7.6
Test script:
---------------
$a = new DOMDocument('1.0', 'UTF-8');
var_dump($a->loadXML('<div x:attr="test">foo</div>')); // returns
true
echo $a->saveXML();
Expected result:
----------------
<br />
<b>Warning</b>: DOMDocument::loadXML(): Namespace prefix x for attr on
div is not defined in Entity, line: 1 in <b>[...][...]</b> on line
<b>2</b><br />
bool(true) <<-- i do not know if it should be true or not
<?xml version="1.0"?>
<div t:attr="test">foo</div>
(xml looks good, all nodes preserved)
Actual result:
--------------
<br />
<b>Warning</b>: DOMDocument::loadXML(): Namespace prefix x for attr on
div is not defined in Entity, line: 1 in <b>[...][...]</b> on line
<b>2</b><br />
bool(true)
<?xml version="1.0"?>
<div attr="test">foo</div>
(t: prefix removed)
--
Edit bug report at https://bugs.php.net/bug.php?id=66850&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66850&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66850&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66850&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66850&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66850&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66850&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66850&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66850&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66850&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66850&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66850&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66850&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66850&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66850&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66850&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66850&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66850&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66850&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66850&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66850&r=mysqlcfg
Thread (9 messages)
- goetas at lignano dot it