Drupal Migrate - Link fields from an XML Source I am using the Migrate (v7.x-2.2) module to migrate records from an XML source into Drupal 7.9.

I've also installed the popular link field module (v7.x-dev).

So far, in my migration class, all built-in fields work well during the migration, but I have not figured out how to migrate link fields from my XML source with their title.

I have two XML source fields (xpaths):

/record/organization/name  &lt;-- I want to migrate this into the link title
/record/organization/url   &lt;-- I want to migrate this into the link url


I am able to get the URL to import using this line in my Migration file (had to use link v7.x-dev module, not 7.x-1.0):

   $this-&gt;addFieldMapping('field_organization', 'organization_url')-&gt;xpath('/record/organization/url');


...but I have no idea how to inject the /record/organization/name into the title argument:

   $this-&gt;addFieldMapping('field_organization', 'organization_url')-&gt;xpath('/record/organization/url')-&gt;arguments(array('title' =&gt; [WHAT GOES HERE?]);
So, the solution is to not use arguments, but instead, fix up the record using the prepare() method:

In the constructor:

//IMPORTANT - DO this source mapping without a destination mapping (NULL)
$this-&gt;addFieldMapping(NULL, 'organization_title')-&gt;xpath('/record/organization/title');

$this-&gt;addFieldMapping('field_organization', 'organization_url')-&gt;xpath('/record/organization/url');


Then, create a method named prepare():

function prepare($node, $rec) {
      $node-&gt;field_organization[LANGUAGE_NONE][0]['title'] = $rec-&gt;organization_title;
}


As of today (Nov 30, 2011), you must have the 7.x-dev version of the link module installed, not the "stable" 1.0 version, in order for link fields to work at all!

Whew!