• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2636
  • Last Modified:

DomDocument :Call to undefined method domdocument::createElement()

Please does anyone no why I would be getting this when running version 5 of php?

faultCode1faultStringWarning:domdocument::domdocument() expects at least 1 parameter, 0 given in C:\Apache\htdocs\ajax\foundations\phptest.php on line 5faultCode1faultStringFatal error:Call to undefined method domdocument::createElement() in C:\Apache\htdocs\ajax\foundations\phptest.php on line
?php
//set the conte type as xml
header ('content type: text/xml');
// create new XML document
$dom = new DOMDocument();

// create the root <response> element
$response=$dom->createElement('response');
$dom->appendChild($response);

//create the <boooks> element and append it as a child of response
$books=$dom->createElement('books');
$response->appendChild($books);

//create the title element for the book
$title=$dom->createElement('title');
$titletext=$dom->createTextNode('Builing responsive web applications with PHP and AJAX');
$title->appendChild($titletext);

//create isbn element
$isbn=$dom->createElement('isbn');
$isbntext=$dom->createTextNode('1-904589-82-5');
$isbn->appendChild($isbntext);

//create the book element
$book=$dom->createElement('book');
$book->appendChild($title);
$book->appendChild($isbn);
//append book as a child of books
$books->appendChild($book);
//build the xml structure is a string variable
$xmlString=$dom->saveXML();
//output the xml string
echo $xmlString;

?>

Open in new window

0
GCF1
Asked:
GCF1
1 Solution
 
hernst42Commented:
See http://www.php.net/manual/en/domdocument.construct.php#86267
Or use
$dom = new DOMDocument('1.0', 'UTF-8');

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now