I am writing a scheduled import using the Migrate module, where I have an XML feed which gives me a number of reports. These reports have most of their fields in common, but have two fields ("location/name" and "desc") which are supplied twice, each specific to a language.

My question is how I could import this into two nodes, one for each language? My first thought went out to using stubs, but thinking on that I can't figure out how.

Ofcourse, the "location/name" and the "desc" elements should only import the one relevant to the language being imported.

Altering XML structure is not possible, data in the fields has been altered for privacy reasons.

Example XML and current code: https://gist.github.com/Tagini/8319661

P.S.: Any help on migrating the location (using Location module) is welcome.


Turns out I didn't look at SimpleXML enough.

Using XPath, I can very easily select one of the languages through the lang attribute, and as such have one language imported.

If i then make a second migration for the other language, my problem is solved.

For reference, the selector for the description now looks like this:

$this->addFieldMapping('body', 'desc')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.