Importing XML using feeds API I have some data of type Images where I want to import in the format of xml named 'images.xml' which containing images url and information.

I want to import this file programatically using feeds API. 

How can I achieve this?

for this i use following code:

$source = feeds_source($importerId);
$config = array(
  'fetcher' =&gt; array(
    'plugin_key' =&gt; 'FeedsHTTPFetcher',
    'config' =&gt; array(
      'auto_detect_feeds' =&gt; FALSE,
      'use_pubsubhubbub' =&gt; FALSE,
      'designated_hub' =&gt; '',
      'request_timeout' =&gt; NULL,
      ),
    ),
  'parser' =&gt; array(
    'plugin_key' =&gt; 'FeedsXPathParserXML',
    'config' =&gt; array(
      'sources' =&gt; array(
        'xpathparser:0' =&gt; 'url',
        ),
      'rawXML' =&gt; array(
        'xpathparser:0' =&gt; 'xpathparser:0',
        ),
      'context' =&gt; '//image',
      'exp' =&gt; array(
        'errors' =&gt; 0,
        'debug' =&gt; array(
          'context' =&gt; 0,
          'xpathparser:0' =&gt; 0,
          ),
        ),
      'allow_override' =&gt; 1,
      ),
    ),
  'processor' =&gt; array(
    'plugin_key' =&gt; 'FeedsNodeProcessor',
    'config' =&gt; array(
      'expire' =&gt; '-1',
      'author' =&gt; 0,
      'authorize' =&gt; 1,
      'mappings' =&gt; array(
        0 =&gt; array(
          'source' =&gt; 'xpathparser:0',
          'target' =&gt; 'url',
          'unique' =&gt; FALSE,
          ),
        ),
      'update_existing' =&gt; '0',
      'input_format' =&gt; 'full_html',
      'skip_hash_check' =&gt; 0,
      'bundle' =&gt; 'images',
      ),
    ),
  'content_type' =&gt; 'images',
  'type' =&gt; 'images',
  'update' =&gt; 0,
  'import_period' =&gt; '-1',
  'expire_period' =&gt; 3600,
  'import_on_create' =&gt; 1,
  'process_in_background' =&gt; 0,
  );
$source-&gt;importer-&gt;addConfig($config);

$featcher_config = $source-&gt;getConfigFor($source-&gt;importer-&gt;fetcher);
$featcher_config['source'] = $url;
$source-&gt;setConfigFor($source-&gt;importer-&gt;fetcher, $featcher_config);
//$source-&gt;save();
//node_save($source);
$source-&gt;startImport();


But this code show "Download of failed with code -1002" and no images are import...
It depends somewhat on your use case. For example are you scraping the images off a web page or are you using a direct image file URL.

If you are scraping from a web page you can use the feeds image grabber module.

That module provides additional settings where you can configure a CSS selector for the page that is in your XML file. 

The module will then request that page and scrape the image from it based on the selector you configured then add the image to the imported item.