One of my expressions for one of my Feed Importers is a count of a specific XML node. The count is often zero. However, for some reason it doesn't seem to want to store that value in the the actual Drupal Node. It doesn't throw any errors, and it doesn't change the value of the field. It will update the field just fine if the value is 1 or more, but as soon as the count is 0 it won't update.

The field in question on the Drupal node is Integer. I've also tried Text, but that doesn't work either, same behavior.

I know the XPath expression works because a) it works just fine any time the value is 1 or greater and b) I'm using XML Tree in Chrome and the expression always works and will return 0 when the count is really 0.

Any ideas?



cdmo’s picture

Is this a bug?

Robin Millette’s picture

cdmo’s picture

I feel like I should give more details, because it does sound like these are related.

Here's the xpath query:

count(/dlf:collection/dlf:record/dlf:items/dlf:item[ncsu:ExtendedItemData/ncsu:Status='TECHLEND' and ncsu:ExtendedItemData/ncsu:Library='DHHILL' and dlf:simpleavailability/dlf:availabilitystatus='available'])

Here's a sample of the feed

If the count is 1 or more, the feed imports fine into content type's field, whether it's an Integer or Text field. When the count is 0, it simply doesn't do anything, it doesn't return a zero, or a "false" or anything else, regardless of the field type.

I've tried to tamper by doing a filter on 0 and return "zero found" instead and that also doesn't work.

I'm guessing that it confuses 0 with FALSE, but you'd think it would return FALSE to a text field if that were the case. Can't quite figure this out.

Also, fwiw I've been using a handy Chrome extension called XML Tree to test queries. It's been very handy.

twistor’s picture

Status:Active» Needs review
new1001 bytes

Can you try this patch?

cdmo’s picture

That fixed it! Thanks a bunch!

If you or anyone else is curious, we're using this module to fetch availability data for our technology lending program at our library. See: and the laptop links on

Planning on rolling out availability data for more of our lending items too. Thanks again.

ps. this is my first patch I've rolled into production. Will I just need to re-apply the patch when there are updates or does this patch get included into the next module update? Just curious.

Robin Millette’s picture

@cdmo: The patch will probably get commited with a message posted here, and its status changed to "fixed" meaning it will be available in the next -dev tarball and eventually, in the next stable release.

cdmo’s picture

Great, thanks for explaining.

Robin Millette’s picture

@cdmo: you could also get fancy with drupal make and have that handle the patch :-)

twistor’s picture

Status:Needs review» Fixed

Thanks for the review!

It will be in the next release.

committed to 7.x

twistor’s picture

Status:Fixed» Closed (fixed)

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