Drupal 8/9 migration Traversing backward on an XML file

Pasan Gamage
1 min readMay 25, 2021

--

This is going to be a very short read. Although I was stuck scratching my head for hours trying to figure out how to traverse backwards of an XML file using XPath selectors.

It was supposed to be simple as using `../` syntax.

selector: '../../../../../@title

Well…., it won’t work if you have your data parse plugin set to XML.

So make sure it is set to simple_xml rather than XML, and you are good to go.

source:
data_parser_plugin: simple_xml

Here are some very helpful links to learn about migrations on D 8/9

https://understanddrupal.com/articles/drupal-migrations-understanding-etl-process
https://understanddrupal.com/articles/writing-your-first-drupal-migration
https://understanddrupal.com/articles/introduction-migration-dependencies-drupal
https://understanddrupal.com/articles/migrating-files-and-images-drupal
https://understanddrupal.com/articles/migrating-xml-files-drupal
https://understanddrupal.com/articles/tips-writing-drupal-migrations-and-understanding-their-workflow
https://understanddrupal.com/articles/workflows-and-benefits-managing-drupal-migrations-configuration-entities

Also, D.O Slack channel will come very handy because the community of people there helped me out to solve this issue. So hats off for them !

--

--

Pasan Gamage
Pasan Gamage

Written by Pasan Gamage

Backend Developer | Motorbike enthusiast

No responses yet