how to import 3 xml selectors in one drupal field ?

Created on 8 November 2021, over 2 years ago
Updated 7 May 2024, about 2 months ago

the migrate_plus migrat conf i had so far was

        # This migration demonstrates importing from a monolithic XML file.
    id: beetween_jobs
    label: 'Migrate beetween jobs from XML file'
    migration_group: default
    source:
      # We use the XML data parser plugin.
      plugin: url
      data_fetcher_plugin: http
      data_parser_plugin: xml
      # Normally, this is one or more fully-qualified URLs or file paths. Because
      # we can't hardcode your local URL, we provide a relative path here which
      # hook_install() will rewrite to a full URL for the current site.
      urls:
        - https://paragraphs.dev.univ-amu.fr/sites/paragraphs.dev.univ-amu.fr/files/ressources_docs/beetween.xml
      # Visit the URL above (relative to your site root) and look at it. You can see
      # that <response> is the outer element, and each item we want to import is a
      # <position> element. The item_xpath value is the xpath to use to query the
      # desired elements.
      item_selector: /root/job
      # Under 'fields', we list the data items to be imported. The first level keys
      # are the source field names we want to populate (the names to be used as
      # sources in the process configuration below). For each field we're importing,
      # we provide a label (optional - this is for display in migration tools) and
      # an xpath for retrieving that value. It's important to note that this xpath
      # is relative to the elements retrieved by item_xpath.
      fields:
        -
          name: title
          label: 'title'
          selector: title
        -
          name: job_description
          label: 'job_description'
          selector: job_description
        -
          name: domaine
          label: 'domaine'
          selector: job_domain
        -
          name: statut
          label: 'statut'
          selector: contract/type
        -
          name: campus
          label: 'campus'
          selector: location/display
        -
          name: study_level
          label: 'study_level'
          selector: study_level
        -
          name: offer_type
          label: 'offer_type'
          selector: offer_type
        -
          name: application_email
          label: 'application_email'
          selector: application_email
      # Under 'ids', we identify source fields populated above which will uniquely
      # identify each imported item. The 'type' makes sure the migration map table
      # uses the proper schema type for stored the IDs.
      ids:
        title:
          type: string
    process:
      # Note that the source field names here (machine_name and friendly_name) were
      # defined by the 'fields' configuration for the source plugin above.
      title: title
      body: job_description
      field_job_diffusion: offer_type
      field_job_statut: statut
      field_job_domaine: domaine
      field_job_campus: campus
      field_job_niveau_etudes: study_level
      field_job_emailapi: application_email
    destination:
      plugin: 'entity:node'
      default_bundle: job
    migration_dependencies:
      required: {  }
      optional: {  }

It works for single XML selector to single field mapping and migration.
I need now to get the value from 3 xml selectors and put them in one multivalued field.

How can i achieve this?
is there any documentation out there ?

πŸ’¬ Support request
Status

Active

Version

5.1

Component

Documentation

Created by

πŸ‡«πŸ‡·France matoeil

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡§United Kingdom joachim

    You need to do something like:

        process:
          myfield/0: source_alpha
          myfield/1: source_beta
    

    (I can't remember the exact syntax for setting deltas, but it's something like that.)

Production build 0.69.0 2024