DOMDocument not found

The module is giving DOMDocument not found error, even though i checked in installation page at start under PHP extensions, DOM was green (enabled)

I even tried to check via code from Core file SystemRequirement.php

/**
     * Check if DOM extension is loaded
     *
     * @return integer
     */
    public function checkPhpXml()
    {
        return extension_loaded('dom') ? 2 : 0;
    }

And its returning me 2, which means DOM is there, but why i am not able to get it working? It says i dont have DOMDocument in my module. Attached is the picture.

Any leads community members?

I am using community edition shop version 6.1.4

Class 'MyModuleName\Core\Utils\Inc\DOMDocument' not found Request XML: ARTSomeInformationWhichIDontWantToExpose20190928143858T1.0SOAP93244

I think you have to use this

$domFile = new \DomDocument();

1 Like

Its still the same. Also i have tried this using at the top

use \DOMDocument;

but no luck

I dont know what the problem is but, when i tried this i am getting the object in return:

What i did:

if (class_exists('DOMDocument')) {
            $doc = new DOMDocument();
            print_r($doc);
            die();
        }

What i got:

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] => 
    [nextSibling] => 
    [attributes] => 
    [ownerDocument] => 
    [namespaceURI] => 
    [prefix] => 
    [localName] => 
    [baseURI] => 
    [textContent] => 
)

@Mohsin_Javaid:

The namespace in your class is:

namespace MyModuleName\Core\Utils\Inc\

If you instantiate the DOMDocument class like this:

$ oDom = new DOMDocument ();

… then PHP interprets your class call like this, and you´ve got your error:

MyModuleName\Core\Utils\Inc\DOMDocument

You have to do it the way @draufgeschaut described it. But note the class notation: Not \DomDocument(); right is: \DOMDocument(). With the slash in Front, PHP uses its own classes.

$ oDom = new \DOMDocument();

1 Like