At times, for web developers content importing appears to be the task which is far from trivial. Writing the import assignment out "from scratch" when aimed at covering each and every instance can't be practical, thus we advice sticking to the ones already in use, say, Migrate, Feeds.
Let us take a close look at Feeds module. It's architecture is made up of a range of plug-ins. The mainstream ones are:
Fetcher: it acts for supllying the data for further parsing and importation;
Parser: performs data parsing and consolidates the arrays of elements for further importng;
Processor: performs data parsing and consolidates the arrays of elements for further importng.
This article is describing how a plug-in for the parser is being written out. We are going to import an XML-file which has been received due to the use of Views Data Export. Voices may be heard stating there is no point in writing a plug-in, as out-of-the-box Feeds provide for its own plug-in that does XML parsing. That is true. In fact, so as to get it operational, one has to make some major alterations to the VDE outlet. As it is, it takes far less effort to write out a parser of your own:
name = Custom Parser description = Contains feeds plugins for XML import. core = 7.x version = 7.x-1.0 files[] = CustomParserXML.inc
hook_feeds_plugins() is being announced wherein we describe our parser plug-in:
/** * Implements hook_feeds_plugins(). */ function custom_parser_feeds_plugins() { return array( 'CustomParserXML' => array( 'name' => t('Custom XML parser'), 'description' => t('Parses XML as we want.'), 'handler' => array( 'parent' => 'FeedsParser', 'class' => 'CustomParserXML', 'file' => 'CustomParserXML.inc', ), ), ); }