Connecting Tech Pros Worldwide Help | Site Map

PHP/DOM Error

Familiar Sight
 
Join Date: Sep 2008
Posts: 253
#1: Jun 17 '09
I'm getting the below error and can't figure out what I'm doing wrong??

I'm using php 5.2.9.9. This is what is in the PHP info file:
Quote:
DOM/XML enabled
DOM/XML API Version 20031129
libxml Version 2.7.3
HTML Support enabled
XPath Support enabled
XPointer Support enabled
Schema Support enabled
RelaxNG Support enabled
Heres my code:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>test</title>
  4.  
  5. </head>
  6. <body>
  7. <?php
  8. $strRssFeed = "http://rss.cnn.com/rss/cnn_world.rss";
  9.  
  10. $xml = implode ('', file($strRssFeed));
  11.  
  12. $dom = domxml_open_mem($xml);
  13.  
  14. $root = $dom->document_element();
  15.  
  16. $title = $root->get_elements_by_tagname("title");
  17. $desc = $root->get_elements_by_tagname("description");
  18. $link = $root->get_elements_by_tagname("link");
  19.  
  20. for($i=0;$i<count($title);$i++)
  21. {
  22. echo "<p>";
  23. echo "<a href=\"".$link[$i]->get_content()."\">".$title[$i]->get_content()."</a>";
  24. echo "<br>".$desc[$i]->get_content();
  25. echo "</p>";
  26. }
  27. ?>
  28. </body>
  29. </html>
And heres the error in the apache logs:
Quote:
PHP Fatal error: Call to undefined function domxml_open_mem()
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,745
#2: Jun 17 '09

re: PHP/DOM Error


Hi.

This means that the DOM XML extension isn't installed on your server. (Or at least, not loaded by that particular script.)
DOMXML is not bundled with PHP5 anymore. If you want to use it, you need to install it. (See here for instructions on that).

You might want to consider using one of the other XML Manipulation methods. Like DOM or SimpleXML.
Reply