0

I am struggling with this problem for hours now... I've succeeded to narrow a problem with Symfony3 and realized it's related to PHP only.

When I execute the following code on 2 different environments (inside / outside a VM), I get 2 different outputs.

$dom = new \DOMDocument();
print_r($dom);

$dom->loadXML('<root><node/></root>');
print_r($dom->documentElement);

Outside the VM :

DOMDocument Object (
    [nodeName] => #document
    [nodeValue] => 
    [nodeType] => 9
    [parentNode] =>
    [childNodes] => (object value omitted)
    [firstChild] =>
    [lastChild] =>
    [previousSibling] =>
    [attributes] =>
    [ownerDocument] =>
    [namespaceURI] =>
    [prefix] =>
    [localName] =>
    [baseURI] =>
    [textContent] =>
)  
Notice: Undefined property: DOMDocument::$documentElement in /var/www/lab/xml/index.php on line 9

Inside the VM:

DOMDocument Object (
    [doctype] =>
    [implementation] => (object value omitted)
    [documentElement] =>
    [actualEncoding] =>
    [encoding] =>
    [xmlEncoding] =>
    [standalone] => 1
    [xmlStandalone] => 1
    [version] => 1.0
    [xmlVersion] => 1.0
    [strictErrorChecking] => 1
    [documentURI] =>
    [config] =>
    [formatOutput] =>
    [validateOnParse] =>
    [resolveExternals] =>
    [preserveWhiteSpace] => 1
    [recover] =>
    [substituteEntities] =>
    [nodeName] => #document
    [nodeValue] =>
    [nodeType] => 9
    [parentNode] =>
    [childNodes] => (object value omitted)
    [firstChild] =>
    [lastChild] =>
    [previousSibling] =>
    [attributes] =>
    [ownerDocument] =>
    [namespaceURI] =>
    [prefix] =>
    [localName] =>
    [baseURI] =>
    [textContent] =>
)  
DOMElement Object (
    [tagName] => root
    [schemaTypeInfo] =>
    [nodeName] => root
    [nodeValue] =>
    [nodeType] => 1
    [parentNode] => (object value omitted)
    [childNodes] => (object value omitted)
    [firstChild] => (object value omitted)
    [lastChild] => (object value omitted)
    [previousSibling] =>
    [attributes] => (object value omitted)
    [ownerDocument] => (object value omitted)
    [namespaceURI] => 
    [prefix] =>
    [localName] => root
    [baseURI] => /var/www/xml/
    [textContent] =>
)

Any idea?

Edit 1 : I have the same config on both environments (from phpinfo) :

xml:
XML Support: active
XML Namespace Support: active
libxml2: Version 2.9.3

libXML:
libXML support: active
libXML Compiled Version: 2.9.3
libXML Loaded Version: 20903
libXML streams: enabled

SimpleXML:
Revision: $Id: b8b5c37931a53e50a937c0aef2a26d351e173215 $
Schema support: enabled

pjehan
  • 820
  • 10
  • 18
  • It simply says that it can not load the content. Maybe your error reporting is to low to see the actual error message. – ThW Mar 15 '17 at 08:17
  • Hi. No, unfortunately the configuration in and outside the VM seems to be exactly the same. In the php.ini file, error_reporting is at 'on' on both environments. – pjehan Mar 15 '17 at 09:02
  • As you can see, outside the VM your ``DOMDocument`` really does not have a ``documentElement`` property in the printed output. I'd suggest you check the output of ``phpinfo()`` to see which XML library and version PHP was compiled with in both environments. – djlauk Mar 15 '17 at 09:13
  • Thanks for your help, I've already checked and it seems to be exactly the same versions. I added the phpinfo in the post subject (Edit 1). – pjehan Mar 15 '17 at 09:40

0 Answers0