Import from feed using a selector only if it has a given XML attribute I'm working on an import from an RSS feed that includes two types of XML &lt;category&gt; elements:


Subject Areas, e.g. &lt;category&gt;Economics | Social and Behavioral Sciences&lt;/category&gt;
Keywords, e.g. &lt;category domain="keywords"&gt;immigration, emigration, immigrants, international migration, poverty, immigration enforcement, asylum policy&lt;/category&gt;


I want to import the Keywords as their own taxonomy field. I can write the YAML as follows, but it predictably imports both Keywords and Subject Areas:

source:
  fields:
    -
      name: keywords
      label: Keywords
      selector: 'category'
process:
  field_keywords:
    -
      plugin: explode
      delimiter: ', '
      source: keywords
    -
      plugin: entity_generate


How do I adjust the selector so it only pulls from the &lt;category&gt; element that includes the domain="keywords" attribute?
I figured this out with the help of an XPATH cheatsheet that shows how selectors I might have written to target HTML would transfer to XPATH values.

To only pull &lt;category domain="keywords"&gt; items, I can use category[@domain="keywords"] as my selector. The other set of &lt;category&gt; items don't have a domain attribute, so I pulled them separately using the selector category[not(@domain)].