Issues Parsing Non-Standard XML Feed with Custom Parser
| Project: | FeedAPI |
| Version: | 6.x-1.x-dev |
| Component: | Code (general) |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
I'm relatively new to FeedAPI and have been tasked with building a site which consumes a series of customized incremental XML feeds which will be utilized to build the site's content.
I've read through some documentation and have made an initial attempt to get the data into the system through a custom parser, but have hit a road block.
My knowledge of the module is light, but I've managed to get the parser working enough so that the FeedAPI mapper module is able to recognize the individual fields returned by the parser, BUT...it does not seem to import any data. And when viewing the Sample Feed Item in the mapper, I only see whichever fields I've chosen assign as the values of "title" and "description" in the returned array. Everything else is empty.
As below:
Array
(
[title] => Carnival Cruise Lines
[description] => Why Carnival ? 'Cause we're just as fun as you, of course! Look, we know it can be tough being the "fun one." So why not let us handle the hard work? Each of our 23 ships feature a heapin' helping ...
[booking_email] =>
[brief_desc] =>
[id] =>
[location] =>
[logodata] =>
[logosize] =>
[logotype] =>
[star_rating] =>
[url] =>
[video_url] =>
[options] => Array
(
[timestamp] => 1254700249
)
)The raw XML for this item follows the schema as below:
<database><table><row>
<id><![CDATA[4]]></id>
<name><![CDATA[Carnival Cruise Lines]]></name>
<location><![CDATA[Miami, Florida US]]></location>
<booking_email><![CDATA[email address goes here]]></booking_email>
<brief_desc><![CDATA[Brief description goes here.]]></brief_desc>
<company_bio><![CDATA[Long description goes here]]></company_bio>
<logodata><![CDATA[long binary string goes here]]></logodata>
<logosize><![CDATA[1777]]></logosize>
<logotype><![CDATA[image/gif]]></logotype>
<url><![CDATA[http://www.carnival.com/]]></url>
<video_url><![CDATA[]]></video_url>
<star_rating><![CDATA[4]]></star_rating>
</row>
</table>
</database>I've attached the code I've managed to patch together after reading various sources about how to build a simpleXML-based parser.
So, if anyone can review what I've managed to put together so far and point me in the right direction, I'd GREATLY appreciate it.
Thanks in advance.
| Attachment | Size |
|---|---|
| parser_simplexml.zip | 4.01 KB |

#1
Likely you want to process your feeds w/ FeedAPI Data processor (if you do not need CCk fields)
http://drupal.org/project/feedapi_data
To really import items, you need a guid or an original_url field as well for each items to decide which item is unique