Just try the dev version, but I've got error :

Importing
An error has occurred.
Please continue to the error page

An error occurred. /batch?id=137&op=do <br /> <b>Fatal error</b>: Call to a member function getSourceElement() on a non-object in <b>/public_html/sites/all/modules/feeds_xpathparser/FeedsXPathParser.inc</b> on line <b>57</b><br />

I took same parameter then the prod version, and add the XPath query for the context...

In addition, I see the option "RegExp" but I don't know how to use the xPath with RegExp... Is it possible to use Xpatch function : http://www.w3schools.com/XPath/xpath_functions.asp ??
Can you add to links to exemple to new user (as me) ? Can you also be more specify on form description : "The query string to run." maybe "the Xquery string to run" or the "Xpath expression to run" ... for me, it's ambiguous.

My current purpose is to import events feed from XML, but the feed contains around 70% of past events. So, I'm looking for also a solution (via Xquery or others) to filter this feed before integration.

Thanks for all your efforts !!

CommentFileSizeAuthor
#16 844654-16-error_handling.patch4.85 KBtwistor

Comments

twistor’s picture

Assigned: Unassigned » twistor
Status: Active » Fixed

This should be fixed in the new dev version. Starting a new issue for documentation as that needs to get done.

twistor’s picture

Title: Bug ! » Call to a member function getSourceElement() on a non-object
steven jones’s picture

Status: Fixed » Active

As far as I can see, this is not fixed in dev.

Issue is, if you have an XML file with more that 50 items in it, feeds will batch up the parsing of the data, which means when FeedsXPathParser->getSourceElement gets called the orginal $this->parser is not around because it doesn't get set up each time (i.e. FeedsXPathParser->parse isn't called.)

I have 'fixed' this by parsing the entire XML file in the parse method in the 'sub parsers', and then just removing the custom getSourceElement implementation.

So I have:


class FeedsXPathParserXML extends FeedsXPathParserHTML {

  public function parse($raw) {

    $xml = new SimpleXMLElement($raw);
    $all_items = $this->query($xml);
    $items = array();
    foreach ($all_items as $item) {
      $this_item = array();
      foreach ($this->sources as $source) {
        $this_item[$source] = $this->getSourceElement($item, $source);
      }
      if (count($this_item)) {
        $items[] = $this_item;
      }
    }
    return $items;
  }
}

So after the initial call to ->parse the parser has returned an array of items, this is how all the other Feeds parsers seem to do it.

twistor’s picture

Your fix is pretty close to how I'll do it. The problem is that we can optimize a bit if we don't go to a string and then create new SimpleXMLElement objects. I need to find out if that's going to make the namespace issues worse. I'll have this fixed soon.

twistor’s picture

I've committed the first fix for this to HEAD, but it needs more testing. Feedback welcome. Should be available in the dev release soon.

Robin Millette’s picture

subscribe!

avantwaves’s picture

Same problem here. I will try the Steve Jones #3 fix... and and will test the dev version as soon you release it. I have a very big feed.... :)

avantwaves’s picture

Exactly in which file you have to change the code? In the FeedsXPathParserHTML.inc inside the feeds_xpathparser module?

twistor’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

tomimikola’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Closed (fixed) » Active
Issue tags: +parser error

I keep getting this error when importing appr. 1000 items. Works fine when testing with ten items.

An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: /batch?id=41&op=do StatusText: OK ResponseText: Fatal error: Call to a member function getNamespaces() on a non-object in /Users/tomi/Sites/D7/sites/all/modules/contrib/feeds_xpathparser/FeedsXPathParser.inc on line 596

Version: 7.x-dev (FeedsXPathParser.inc,v 1.1.2.23.2.17)

maksis’s picture

exactly the same problem here, just trying to import one item

sachbearbeiter’s picture

same problem with 20 items

twistor’s picture

Status: Active » Postponed (maintainer needs more info)

@TomiMikola, maksis, sachbearbeiter, I will need more information to be able to reproduce your errors exactly as I am not getting them.

@TomiMikola, There's a good chance that you're running out of memory, from trying to import so many items.

Ooxo’s picture

Drupal: 7.4
Feeds: 7.x-2.0-alpha4 + (Patch applied for taxonomy and language awareness)
Feeds XPath Parser: 7.x-1.x-dev (23/07)

Strangely enough I import my articles from node "Feeds" (with drush cron and Feeds XPath Parser) but when I try to import my xml file from a standalone form I get
Fatal error: Call to a member function getNamespaces() on a non-object in ../sites/all/modules/feeds_xpathparser/FeedsXPathParserDOMXPath.inc on line 12

I imported 10000 items just fine, I don't remember changing anything and then going for 10000 more items and got the error screen

the xml file sample (the full xml file as been checked on http://validator.w3.org/check and recieved a valid stamp)

<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
<channel>
<title>My Site</title>
<link>http://www.example.com</link>
<description>Products</description>
<item>
<guid>EN-385173830</guid>
<guidfr>FR-385173830</guidfr>
<title><![CDATA[product name]]></title>
<date><![CDATA[07/19/2011]]></date>
<keywords><![CDATA[keyword 1]]></keywords>
<keywords><![CDATA[keyword 2]]></keywords>
<keywords><![CDATA[keyword 3]]></keywords>
<body><![CDATA[Description]]></body>
<sku><![CDATA[385173830]]></sku>
<currency><![CDATA[USD]]></currency>
<saleprice><![CDATA[]]></saleprice>
<price><![CDATA[xxxx]]></price>
<retailprice><![CDATA[xxxx]]></retailprice>
<fromprice><![CDATA[]]></fromprice>
<buyurl><![CDATA[link 1]]></buyurl>
<impressionurl><![CDATA[link 2]]></impressionurl>
<imageurl><![CDATA[link 3]]></imageurl>
<catalog><![CDATA[Category 1 taxo]]></catalog>
<brand><![CDATA[Brand Taxo]]></brand>
</item>
......

I can't figure why the standalone form won't work anymore !?!
Any help/advice would be greatly appreciated ;)

twistor’s picture

Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new4.85 KB

@OoxO,

I have a patch that I'd like you to try out. It provides more robust error handling, which hopefully will tell you what the error is.
I'm going to commit it anyway, but I'll post it for people without git.

Ooxo’s picture

@twistor
Many thanks for this patch, works like a charm :

CData section not finished Surface material: 75% cotton, 25% polyester Fille on line 178943. Error code: 63
PCDATA invalid Char value 8 on line 178943. Error code: 9
Sequence ']]>' not allowed in content on line 178943. Error code: 62
internal error on line 178943. Error code: 1
Extra content at the end of the document on line 178943. Error code: 5

Checking the line, there's a little special character :( ...Very very helpful, thanks again

twistor’s picture

Status: Active » Fixed

Installing tidy for php might help. Once it's installed, you can enable it in the XPath config.

caktux’s picture

Great error handling patch, thanks!

twistor’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Fixed » Patch (to be ported)
twistor’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)
Issue tags: -parser error

Automatically closed -- issue fixed for 2 weeks with no activity.