I’m using feed import module in Drupal 7 cms that accepts xpath directives to map the data for the import. Is it possible to select only part of the atomic value or explode it with xpath?
For example:
<book>
...
<categories>1,4,88</categories>
...
</book>
Is it possible to get only 1 or 4 or 88 separately with xpath statement?
You can use the substring-before() and substring-after() functions:
substring-before(/book/categories, ',')substring-before(substring-after(/book/categories, ','), ',')substring-after(substring-after(/book/categories, ','), ',')With XPath 2.0 you could use the tokenize() function:
tokenize(/book/categories, ',')[1]tokenize(/book/categories, ',')[2]tokenize(/book/categories, ',')[3]