Closed (won't fix)
Project:
Feed Import
Version:
7.x-2.7
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Feb 2014 at 00:04 UTC
Updated:
10 Jun 2014 at 11:39 UTC
Jump to comment: Most recent
In 7.x-2.6 you could use XPath to target Dates and the filter would receive an array of 3 arrays where the child elements are key/value pairs (ie StartDate, EndDate, etc). This same XPath in 7.x-2.7 sends an empty value to my filter function. Is there any way to do the same thing with 7.x-2.7?
<?xml version="1.0" encoding="utf-8"?>
<CalendarOfEvents>
<Event>
<Dates>
<Item>
<StartDate>11/29/2013</StartDate>
<EndDate>11/29/2014</EndDate>
<StartTime>09:00:00 AM</StartTime>
<EndTime>05:00:00 PM</EndTime>
</Item>
<Item>
<StartDate>12/6/2013</StartDate>
<EndDate>12/6/2014</EndDate>
<StartTime>09:00:00 AM</StartTime>
<EndTime>05:00:00 PM</EndTime>
</Item>
<Item>
<StartDate>12/13/2013</StartDate>
<EndDate>12/13/2014</EndDate>
<StartTime>09:00:00 AM</StartTime>
<EndTime>05:00:00 PM</EndTime>
</Item>
</Dates>
</Event>
</CalendarOfEvents>
Comments
Comment #1
Sorin Sarca commentedHi,
could you post your xpath?
Comment #2
blake.thompson commentedParent item xpath is //Event, field xpath is Dates
Comment #3
Sorin Sarca commentedOk, I don't know if this is a good fix but you should try it.
Open feed_import.inc.php file and find the getXpathValue function (around line 410). Replace it with this function:
Comment #4
blake.thompson commentedThanks, that got it a little closer. I made a change in the while statement which will convert a SimpleXMLElement into an array. I believe I read this will only use UTF-8 encoding, so if someone's data is using another encoding this won't work for them. Otherwise I think a recursive conversion function would be necessary, or each XML element would have to be handled in its own filter function.
Also, if someone was targeting the xpath equivalent of Dates as I was (where in 7.x-2.6 targeting Dates or Dates/Item would have yielded the same thing), this will now require the xpath to target Dates/Item.
Comment #5
Sorin Sarca commentedWell, the filter function should handle any encoding issues.
Also, this line
should have only an array cast (nested items won't be converted to an array, but again, the filter function should handle them).
Maybe this fix needs more test in order to release it.
As the project page says, I'm looking for maintainers, and if you want (and you are interested) I can add you as maintainer.
Comment #6
blake.thompson commentedWill convert the array and anything nested into an associative array, otherwise I'd have to go back through each of my filter functions that expect arrays and do the same thing, or a string conversion for each value. This just seemed easier for my use case. I can see why just typing it to an array to let filter functions handle the data would be more appropriate though.
With this change and updating my xpath where necessary everything is working as expected importing about 1500 nodes.
I'd consider helping out as a maintainer, I haven't helped maintain a module before so if you wanted to contact me and let me know how that'd work that'd be great.
Comment #7
Sorin Sarca commentedSince for version 2 is approaching end of life, I'll focus more on version 3.
Anyway, if you still want and have time to help developing this module just contact me.