1

How would you migrate a complex data structure in XML format, such as:

<products>
  <product>
    <name>Product 1</name>
    <price>3.99</price>
    <colour-options>
      <colour>red</colour>
      <colour>blue></colour>
    <colour-options>
  </product>
</products>

How would you migrate data in this format, into a content type? I'm guessing that the best way would be using the Migrate module.

2

Migrate can help you with this.

You can extend XMLMigration and use MigrateSourceXML.

I have a partial stack exchange data import which uses this with code on github.

  • @dylan-spencer-james Additionaly for the "complex stuff" you're talking about you may write a "2 step" migration. Here I would write 1 XML Migration that migrates just Products without color data. Then a 2nd migration after the 1st that migrates solely the Color data into new Nodes and references them back to each Product you've already made. This multiple step stuff is covered in the official Migrate examples bundled with Migrate itself. – tenken Dec 6 '13 at 16:03
  • @jeremy-french - I am trying to a similar thing as you, however my XML rows don't have a unique id. I posted my question here: drupal.stackexchange.com/questions/185304/… – user1015214 Dec 30 '15 at 14:22
1

I don't think that Migrate can help you on that case. I think you should give a look into Feeds and other modules helper.

If you can find a submodule that will help you parse your XML, you can easier create your own with the great API that Feeds provide.

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.