| Creating a parser |
|
The component does support the major formats of CSV files. Using the mapping in feed configuration any CSV file (with a header row) should work. Problem might be that the 'description' field has a different name, and there is no mapping for the description. This can be solved easily using a callback function. If the data is only available in xml format the existing parsers will probably not work. Still you might give it a try many feeds use 'item' or 'product' as tag and the Affiliates (item) or Tradetracker (product) parser might work. Otherwise the solution is to add you own parser. The component allows to add two custom parsers: Create a file xml_custom.inc in administrator/components/com_datafeeds/cron In this file you can put your own parser. Most basic duplicating the existing parser: (SVN:1035) Class MyXMLParser extends TradetrackerRSS{
Next step would be to copy the relevant functions from the TradetrackerRSS class (start element and end element) and alter the code. On the page about 'adding share a sale' feeds you can find an example of a custom parser. Â Example basic parserThe parser below can be used for simple xml structures without tree's or attributes. The class is included in recent versions (svn:1149) of xml_fetch.inc
<?phpUsageEither copy the code into the file xml_custom.inc and modify the code as desired. Or use a child class Â
<?php This parser will parse the xml below, however tweaks are needed since the mandatory field 'description' is not present, and the image's will pile up. This can be solved using a callback function, or by customizing the parser.  |
