通过 XPath 加入子值?

Join child values via XPath?

我知道如果我有非唯一的子节点('concat'),我的问题将很容易解决。

问题:

<CarPlant>
      <Model>Audi</Model>
      <Model>Scoda</Model>
</CarPlant>

我想得到一个字符串,例如"Audi,Scoda"用scala的方式处理。

这个 XPath 2.0 表达式,

/CarPlant/string-join(Model,',')

将评估为

Audi,Scoda

根据要求为您的 XML。