2

I am trying to load xml in php

$doc = new DOMDocument();
$doc->load("LoginVal.xml");

I am getting an error as

Warning: domdocument::domdocument() expects at least 1 parameter, 0 given in C:\Program Files\Apache Group\Apache2\htdocs\hello.php on line 5

Fatal error: Call to undefined method domdocument::load() in C:\Program Files\Apache Group\Apache2\htdocs\hello.php on line 7

Regards, Hemant

0

5 Answers 5

1

Obiviously there is a parameter missing in the constructor. Try something like

$dom = new DOMDocument('1.0', 'iso-8859-1');
Sign up to request clarification or add additional context in comments.

Comments

0

The Fatal error is because the object was instantiated the warning is as it says it is expecting a parameter check https://www.php.net/manual/en/domdocument.construct.php

Comments

0

Take a look at the comment in here, this looks like a known issue (especially comment #2).

Comments

0

Please read the user-comments in DOMDocument::__construct(). There is a talk about exactly this error when using PHP5 on Windows machines (which most likely matches your configuration). I'm quoting christian dot reinecke at web dot de:

[...] make sure you're not overwritting this dom library by another (f.e. extension=php_domxml.dll in php.ini). XAMPP f.e. delivers its standard version with php_domxml.dll which ends up in this error message

Make sure that there is no php_domxml.dll-extension in your php.ini.

Comments

0

try the full file path

Yours

$doc = new DOMDocument();
$doc->load("LoginVal.xml");

Try

$doc = new DOMDocument();
$doc->load("/path/to/LoginVal.xml");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.