The Migrate API provides various services for migrating data from different sources to Drupal 9 (or later). Today we are going to learn how to migrate data from online xml file to our site of Drupal 9.
The prerequisite contrib modules are : Migrate Plus, Migrate Tools, Migrate.
For setting up folder structure and creating migration group and other migration file refer to this blog. The basic setup for doing custom migration is thoroughly explain under this blog. Now to migrate the data from online xml to our site we just need to define 4 sections in our migration. They can appear in any order, but we need all four i.e. General information, source, destination, and data processing. File snapshot is provided for reference.
Now enable the module by running “drush en rss_xml”
After the module gets successfully enabled check the status of your migration script by running “drush migrate:status rss_xml_sample”
As you can see, all these results are inside snapshots.
Here we can see that migration has stated Idle and there are 26 items waiting for import.
Now lets see the snapshot of our content type rss_data in Drupal and see whether it has content present or not.
Fields of rss_data content type:
Content/Nodes of rss_data content type:
Now Lets run the script to import the data from xml to Drupal 9:
drush migrate:import rss_xml_sample
Here in the snapshot, we can see that 26 items successfully imported into our site. Check snapshots for reference.
Data inside nodes of rss_data content type
Data migrated successfully; lets check a node in edit mode
Conclusion: Data has been successfully migrated from XML to the Drupal 9 Site. In this example, I have migrated nodes data to Drupal site. In case you have any other questions regarding the same, comment down below and I’ll help to answer them all.