tags:

views:

71

answers:

5

Hi All,

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

A: 

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

Lizard
parameters are optional according to the doc..
RC
A: 

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

RC
+1  A: 

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

$dom = new DOMDocument('1.0', 'iso-8859-1');
msparer
A: 

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.

Stefan Gehrig
A: 

try the full file path

Yours

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

Try

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