Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOMDocument error 1

Status
Not open for further replies.

richardko

Programmer
Jun 20, 2006
127
US
Hi,
I am trying to use the php5 's DOM extension but i am getting error.
The code I am trying to execute is:

<?php
$dom = new DOMDocument;
$dom->load("book.xml");
print "<pre>";
print $dom->documentElement->nodeName;
print "<br/>\n";
//does not work...
//print $dom->getElementsByTagName("book")[0];

print_r( $dom->getElementsByTagName("book"));
print "<br/>\n";

print htmlentities($dom->saveXML());
?>


This is an example I found. It gives error:
PHP Fatal error: Class 'DOMDocument' not found in /home/test.php on line 2

Any idea?
I am using php 5.0. Here is version output:

PHP 5.1.6 (cli) (built: Dec 15 2006 10:43:55)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
 
It may make a difference on what platform you're running PHP and how you installed it. This page at CodeWalkers mentions, for example, that the PHP package that comes the Fedora Core 4 has DOM turned off.

If you look at the output of a script that reads:

Code:
<?php
phpinfo();
>?

does that output mention DOM?



Want the best answers? Ask the best questions! TANSTAAFL!
 
Thanks for the reply.
You were right, DOM was turned off. Do i need to recompile php to use DOM?
 
I would, but I usually install PHP from source code every time anyway. That page I linked to at CodeWalkers talks about additional PHP packages that might enable the additional functionality.



Want the best answers? Ask the best questions! TANSTAAFL!
 
thanks for the quick replay again.
Installing php-xml seems to have fixed it.
thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top