0

I have a dataset content type and an xml structure like this:

<dataset>
   <purpose>blah blah</purpose>
   <abstract>blah blah</abstract>
   <authors>blah blah1, blah blah2</authors>
   <ordered-authors>
      <author>blah blah</author>
      <author>blah blah</author>
      <author>blah blah</author>
   </ordered-authors>
   <tags>
      <themes>
         <theme name="xxx" rank="1"/>
         <theme name="yyy" rank="1"/>
      </themes>
   </tags>
</dataset>

I want to get the multiple attributes of each theme tag into a form like: xxx-1, yyy-2, etc. which will be used as entity references for each dataset, whether as an array, or a list that I then implode via a tamper. In Drupal 7 there were "dummy" fields to hold temporary values - I could create extra fields in the content type for this purpose but so far, that hasn't helped me find any way to query the xml and/or use available tamper options to combine the nested attributes to get a usable array of concatenated values (short of giving up with the feeds interface and moving to migrate). ANY help or suggestions would be appreciated!

1 Answer 1

0

Well, I have a solution but it's not elegant. I used this query: //theme/@name|//theme/@rank

and Imploded the resulting array to get theme1,rank1,theme2,rank2, etc,

then used a regex to replace every odd comma with a dash: /(\w+)\W*,\W*(\w+)/ $1-$2

and then Exploded back to an array.

Would still like to know if there's a better alternative.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.