Bug #66850 [Nab]: Different behaviors of loadXML
Edit report at https://bugs.php.net/bug.php?id=66850&edit=1
ID: 66850
User updated by: goetas at lignano dot it
Reported by: goetas at lignano dot it
Summary: Different behaviors of loadXML
Status: Not a bug
Type: Bug
Package: DOM XML related
Operating System: windows/linux (ubuntu)
PHP Version: 5.5.10
Block user comment: N
Private report: N
New Comment:
I agree with you, that is an libxml issue,
But sounds strange that:
// NOT valid XML
laodXML('...') // return false
// Valid XML
laodXML('<div/>') // return true
// NOT Valid XML
laodXML('<t:div/>') // return true but should be false
I do non know about libxml internals, but if it raises a warning, can it be used to sets to
'false' the "laodXML" return value?
Previous Comments:
------------------------------------------------------------------------
[2014-03-11 15:12:20] ab@php.net
Have you already played with the properties available in the DOMDocument? That way you could affect
the behavior of the libxml in some way, maybe that helps.
But generally I can just repeat that an invalid XML has an unpredictable effect, even if you prefer
to call it a libxml issue :) Like say a namespace string itself isn't that important, the
important thing is the URI which should have been defined. Say two namespaces a: and b: might be the
same in different documents if they were defined with the same URI. But this all is actually far
from the case if you had a perfectly valid document.
------------------------------------------------------------------------
[2014-03-11 14:40:56] goetas at lignano dot it
The decision if "DOMDocument::loadXML" worked properly, should be based only on
"loadXML" return value.
Should not be linked to warnings or internal libxml issues.
Currently i have to check if "loadXML" returns true and also if
"libxml_get_errors" is emply or not...
------------------------------------------------------------------------
[2014-03-11 14:22:19] ab@php.net
You can see the relevant code here http://lxr.php.net/xref/PHP_5_6/ext/dom/document.c#dom_document_parser
. Generally we rely on libxml, so if it could parse, that's the precondition for the DOM
extension to work further.
------------------------------------------------------------------------
[2014-03-11 12:59:51] goetas at lignano dot it
But if it is not a bug, why loadXML() returns a 'true'?
------------------------------------------------------------------------
[2014-03-11 10:06:42] ab@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
There are two points why it's not a bug:
- loading an invalid XML document (or say some HTML4) has always an unpredictable effect, especially
if there's no validation happened before
- what you mention as a difference in handling is up to the libxml version, it has nothing to do
with the OS. When different dependency libs are used, the some discrepancy is even expected.
Depending on what you do, you can always use the latest libxml by doing a custom build.
Thanks
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=66850
--
Edit this bug report at https://bugs.php.net/bug.php?id=66850&edit=1
Thread (9 messages)