Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
I have complex data structures in an XML export that I need to run through a custom process plugin which will upload files etc then save entities and return those entity ids as part of an entity reference field. In my migrate_plus migration config I have the field set to an attachments field which looks something like this:
<attachments>
<attachment1>
<title><![CDATA[Document 1]]></title>
<url><![CDATA[example.com/document1.pdf]]></url>
</attachment1>
<attachment2>
<title><![CDATA[Document 2]]></title>
<url><![CDATA[example.com/document2.pdf]]></url>
</attachment2>
</attachments>
But my process plugin receives an empty string because the Xml parser casts the field values as strings.
Proposed resolution
Check at a field level if we have complex data and cast appropriately.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2792765-allow-xml-values-1.patch | 1.07 KB | acbramley |
Comments
Comment #2
acbramley CreditAttribution: acbramley commentedSomething like this could work. Maybe there's already a way to do this, I'm not too sure.
Comment #3
Grayside CreditAttribution: Grayside at Phase2 for Norwegian Cruise Line commentedPotentially related to #2787157: XML Import xpath not working
Comment #4
Grayside CreditAttribution: Grayside at Phase2 for Norwegian Cruise Line commentedComment #6
mikeryanCommitted, thanks!