Call to undefined method DOMDocument::create_element()

Hi,

This is my code:-

// Start XML file, create parent node
$doc = new DOMDocument(“1.0”);
$node = $doc->createElement(“markers”);
$parnode = $doc->appendChild($node);

I am getting error:-

Fatal error: Call to undefined method DOMDocument::create_element() in C:\xampp\htdocs\articles-phpsqlajax\phpsqlajax_genxml.php on line 6

Please help !!!

The error message refers to the method create_element instead of createElement. Did you use that method anywhere else?

I tried both createElement and create_element.
create_element - error is -
Call to undefined method DOMDocument::create_element()
createElement - error is -
This page contains the following errors:
error on line 2 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.

createElement() is the method you should be using according to the PHP docs. That’s why I was wondering where the error message was picking up create_element() from.

the code you have posted works fine. the problem must originate somewhere else.

Is it the issue for xampp ?
I think xampp might have some missing extension.
I checked and also I can see DOM/XML extension enabled. Do I need something else for DOMXML or thats it?

again, the error message you posted does not match the code you posted. check the file mentioned in the error message at the specified position (and around that, since the cause might be a couple of lines earlier).

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.