代码之家  ›  专栏  ›  技术社区  ›  27P

通过XPath连接子值?

  •  0
  • 27P  · 技术社区  · 7 年前

    我知道如果我有非唯一的子节点(通过“concat”)的话,我的问题将很容易得到解决。

    问题:

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

    我想得到一个字符串,例如“Audi,Scoda”,用scala的方法处理它。

    1 回复  |  直到 7 年前
        1
  •  2
  •   kjhughes    7 年前

    XPath 2.0表达式,

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

    将评估为

    Audi,Scoda
    

    按要求为您的XML。