Fatal error: Call to a member function getElementsByTagName() on a non-object in example.com\web\modules\amazontools\amazon.php5.inc on line 195

This is on a site that has worked for several days. I was updating a page that contains amazon filter elements but I was not changing them, just adding extra text at the end of the page. I clicked preview and bang, down went the page. It seems a drastic reaction to whatever happened.

I did a reload and Drupal displayed the following message.
warning: DOMDocument::loadXML() [function.loadXML]: Empty string supplied as input in examplecom\web\modules\amazontools\amazon.php5.inc on line 328.

After that the error went away.

Comments

Prometheus6’s picture

I think you have the wrong module.

http://drupal.org/project/amazon_filter

I note it only has a 4.7 dev release.

peterx’s picture

Hello Prometheus6,
I am experimenting with amazontools and amazon filter to place links to Amazon products in existing Web pages. The result will be proposed as part of a volunteer Web site to raise money for a community not-for-profit organization. I would like to use amazontools initially to supply information to existing pages. Later on the amazontools nodes could be used for products that do not fit the current Web pages.

I tried following the code backwards from the error to amazon filters then forward to see where an error might occur. If there is a better way to do this then I am happy to work on it. I could supply the result as an option to add to amazontools if you are not already working on something similar.

amazon_filter calls _amazon_product_data_from_Amazon which converts an ASIN list to the search parameters. If the ASIN list was bad, I would expect an error in _amazon_product_data_from_Amazon.

_amazon_product_data_from_Amazon calls amazon_get_items which calls amazon_get_DOM. amazon_get_DOM passes the parameters to amazon_get_XML which passes them to amazon_search_RESTURI. There is an unused amazon_search_RESTURI in _amazon_seach_search that looks like it should have been commented out with the message log that follows it.

amazon_search_RESTURI converts the parameters to a search string. amazon_search_RESTURI seems to be coded to weed out invalid parameters and produce an empty array that is then merged with valid parameters. If amazon_filter had passed a bad parameter then surely there would be an error in amazon_search_RESTURI, not later on.

_amazon_product_data_from_Amazon then passes the results of amazon_get_DOM to _amazon_items_array_from_DOM. The Fatal Error error occurred in _amazon_items_array_from_DOM. At this stage I cannot see how an error in amazon filters could get through two layers of amazontools code that uses the input to build other forms of parameters.

Perhaps you could tell me the correct way to get information from amazon tools for use in a tag replacement filter. I wrote some modules to convert XML tags to node information and could convert one to expand a tag to an amazon link using amazon tools so long as I know the "correct" functions to use from amazontools.

I currently use the amazon_filter to get images for books. I might get a price later on. I do not create nodes for amazon products as the descriptive nodes are already in another module. I do not mind creating a node if that is required and can be done through your functions. The node could could be created the first time I request information for product. Is there a correct function to call to find if a product is in amazontools and is there a correct function to call to create a new product node?

jt6919’s picture

The absolute exact same thing happens to me, but I am NOT using Amazon filter.

I have a drupal 5.1 install with Curl and domxml installed, and when I do amazon item import, I get the first error, reload and gives the second error (stated above). It never imports anything. I am using php 5.2.6.

jt6919’s picture

I upgraded a 4.7 site to 5.1 today, and now I get the exact same error (not using amazon filter, just amazon tools). I got the error just while running cron.php:

Fatal error: Call to a member function getElementsByTagName() on a non-object in /home/smorgasb/public_html/modules/amazontools/amazon.php5.inc on line 195

hyperlogos’s picture

Version: 5.x-1.2 » 5.x-1.5
Priority: Normal » Critical

I have the same problem. The errors come up whether trying to create or edit amazon nodes. I get precisely the same errors. Attempt to do anything but display an amazon, and get the first error. Go to another page, find the other error in the status. This makes the module unusable for me. I've tried all kinds of things including CVS but nothing helps. Please solve this bug, if I can not fix it I can not use amazontools. (I've seen at least one site out there in the world that displays these errors, by the way - so it's happening to live sites in the real world.)

If you need more information then by all means say so! But don't just leave us hanging. This error STILL PERSISTS TODAY, I have tried both the latest release and the CVS.

hyperlogos’s picture

I have the same problem. The errors come up whether trying to create or edit amazon nodes. I get precisely the same errors. Attempt to do anything but display an amazon, and get the first error. Go to another page, find the other error in the status. This makes the module unusable for me. I've tried all kinds of things including CVS but nothing helps. Please solve this bug, if I can not fix it I can not use amazontools. (I've seen at least one site out there in the world that displays these errors, by the way - so it's happening to live sites in the real world.)

If you need more information then by all means say so! But don't just leave us hanging. This error STILL PERSISTS TODAY, I have tried both the latest release and the CVS.

hyperlogos’s picture

Sorry about the double comment, drupal.org is the slowest site ever. I'm on a modem and I spend my time waiting for the site and not the other way around :(

Dabitch’s picture

I nevr had this problem before but I've unly just upgraded from 5.3 to 5.5 and now i get the "modules/amazontools/amazon.php5.inc on line 328." error. (path is edited). It happens if I run cron, edit a an amazon node or try and post an amazon node.

	•	warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Premature end of data in tag URL line 1 in Entity, line: 1 in /drupal/sites/default/modules/amazontools/amazon.php5.inc on line 328.
	•	warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Premature end of data in tag LargeImage line 1 in Entity, line: 1 in /drupal/sites/default/modules/amazontools/amazon.php5.inc on line 328.
	•	warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Premature end of data in tag Item line 1 in Entity, line: 1 in /drupal/sites/default/modules/amazontools/amazon.php5.inc on line 328.
	•	warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Premature end of data in tag Items line 1 in Entity, line: 1 in /drupal/sites/default/modules/amazontools/amazon.php5.inc on line 328.
	•	warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Premature end of data in tag ItemLookupResponse line 1 in Entity, line: 1 in /drupal/sites/default/modules/amazontools/amazon.php5.inc on line 328.
wayland76’s picture

wayland76’s picture

Status: Active » Closed (duplicate)

Everyone else, this is a duplicate of http://drupal.org/node/143565

Not that that has any answers on it.

atiqorakzai@hotmail.com’s picture

Hi All!

I am trying to fetch news from an external site ( http://feeds.feedburner.com/Ecouterre?format=xml ) via RSS. Actual site link is http://www.ecouterre.com/ . I am using below code but I am getting error , fatal error: call to a member function getelementsbytagname() on a non-object . Also it works fine for other sites. Please help me , its very important. Thanks in advance.

Kan

Code:

$xml=("http://feeds.feedburner.com/Ecouterre?format=xml");
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);

//get elements from "<channel>"
$channel=$xmlDoc->getElementsByTagName('channel')->item(0);
$channel_title = $channel->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
$channel_link = $channel->getElementsByTagName('link') // Line 9
->item(0)->childNodes->item(0)->nodeValue;   // Line 9
$channel_desc = $channel->getElementsByTagName('description')
->item(0)->childNodes->item(0)->nodeValue;
//get and output "<item>" elements
$x=$xmlDoc->getElementsByTagName('item');
for ($i=0; $i<1; $i++)
  {
  $item_title=$x->item($i)->getElementsByTagName('title')
  ->item(0)->childNodes->item(0)->nodeValue;
  $item_link=$x->item($i)->getElementsByTagName('link')
  ->item(0)->childNodes->item(0)->nodeValue;
  $item_desc=$x->item($i)->getElementsByTagName('description')
  ->item(0)->childNodes->item(0)->nodeValue;

  echo ("<p><a href='" . $item_link
  . "'>" . $item_title . "</a>");
  echo ("<br />");
  echo ($item_desc . "</p>");
  }

Fatal error: Call to a member function getElementsByTagName() on a non-object in /home/a4560036/public_html/king/ecorazzi.php on line 9