{"id":57452,"date":"2023-05-27T09:42:14","date_gmt":"2023-05-27T04:12:14","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=57452"},"modified":"2023-05-30T13:19:41","modified_gmt":"2023-05-30T07:49:41","slug":"migrate-data-from-online-xml-to-drupal-9","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/migrate-data-from-online-xml-to-drupal-9\/","title":{"rendered":"Migrate Data from online XML to Drupal 9"},"content":{"rendered":"<p>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.<\/p>\n<p>The prerequisite contrib modules are : <strong>Migrate Plus, Migrate Tools, Migrate.<\/strong><\/p>\n<p>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.<\/p>\n<p><strong>migrate_plus.migration.rss_xml_sample.yml<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-57525 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog9-2-459x1024.png\" alt=\"\" width=\"459\" height=\"1024\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog9-2-459x1024.png 459w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog9-2-135x300.png 135w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog9-2-768x1713.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog9-2-689x1536.png 689w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog9-2-918x2048.png 918w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog9-2-624x1392.png 624w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog9-2.png 1226w\" sizes=\"(max-width: 459px) 100vw, 459px\" \/><\/p>\n<p><strong>migrate_plus.migration_group.rss_xml_group.yml<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-57524 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog10-1024x190.jpg\" alt=\"\" width=\"625\" height=\"116\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog10-1024x190.jpg 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog10-300x56.jpg 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog10-768x142.jpg 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog10-1536x285.jpg 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog10-2048x379.jpg 2048w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog10-624x116.jpg 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p><strong>rss_xml.info.yml<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-57523 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog11-1-1024x190.png\" alt=\"\" width=\"625\" height=\"116\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog11-1-1024x190.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog11-1-300x56.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog11-1-768x142.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog11-1-1536x285.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog11-1-2048x379.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog11-1-624x116.png 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>Now enable the module by running &#8220;<strong>drush en rss_xml<\/strong>&#8221;<\/p>\n<p>After the module gets successfully enabled check the status of your migration script by running &#8220;<strong>drush migrate:status rss_xml_sample<\/strong>&#8221;<\/p>\n<p>As you can see, all these results are inside snapshots.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-57528 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog4-1-1024x469.png\" alt=\"\" width=\"625\" height=\"286\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog4-1-1024x469.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog4-1-300x137.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog4-1-768x352.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog4-1-1536x703.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog4-1-2048x937.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog4-1-624x286.png 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>Here we can see that migration has stated Idle and there are 26 items waiting for import.<\/p>\n<p>Now lets see the snapshot of our content type rss_data in Drupal and see whether it has content present or not.<\/p>\n<p><strong>Fields of rss_data content type:<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-57531 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog1-1-1024x437.png\" alt=\"\" width=\"625\" height=\"267\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog1-1-1024x437.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog1-1-300x128.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog1-1-768x328.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog1-1-1536x655.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog1-1-2048x874.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog1-1-624x266.png 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p><strong>Content\/Nodes of rss_data content type:<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-57530 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog2-1-1024x349.png\" alt=\"\" width=\"625\" height=\"213\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog2-1-1024x349.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog2-1-300x102.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog2-1-768x262.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog2-1-1536x524.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog2-1-2048x698.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog2-1-624x213.png 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p><strong>Now Lets run the script to import the data from xml to Drupal 9:<\/strong><\/p>\n<p><strong>drush migrate:import rss_xml_sample<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-57528 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog4-1-1024x469.png\" alt=\"\" width=\"625\" height=\"286\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog4-1-1024x469.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog4-1-300x137.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog4-1-768x352.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog4-1-1536x703.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog4-1-2048x937.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog4-1-624x286.png 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>Here in the snapshot, we can see that 26 items successfully imported into our site. Check snapshots for reference.<\/p>\n<p><strong>Data inside nodes of rss_data content type<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-57529 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog3-1-1024x494.png\" alt=\"\" width=\"625\" height=\"302\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog3-1-1024x494.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog3-1-300x145.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog3-1-768x371.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog3-1-1536x742.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog3-1-2048x989.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog3-1-624x301.png 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p><strong>Data migrated successfully; lets check a node in edit mode<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-57526 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog6-1-1024x552.png\" alt=\"\" width=\"625\" height=\"337\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog6-1-1024x552.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog6-1-300x162.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog6-1-768x414.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog6-1-1536x828.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog6-1-2048x1103.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/mgblog6-1-624x336.png 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p><strong>Conclusion: <\/strong>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&#8217;ll help to answer them all.<\/p>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1516,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":14},"categories":[3602],"tags":[3601,4884],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/57452"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1516"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=57452"}],"version-history":[{"count":2,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/57452\/revisions"}],"predecessor-version":[{"id":57532,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/57452\/revisions\/57532"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=57452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=57452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=57452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}