XQuery:如何在 for 循环中正确追加 [英] XQuery: how to properly append , in for loop

查看:31
本文介绍了XQuery:如何在 for 循环中正确追加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有这样的 xml 数据:

So I have xml data like this:

  <PhoneNumber>213-512-7457</PhoneNumber>
  <PhoneNumber>213-512-7465</PhoneNumber>

使用这个 XQuery:

and with this XQuery:

<PhoneNumberList>
{
  for $phone in $c//PhoneNumber
  let $phoneStr := ""
  return concat($phoneStr, $phone) 
}
</PhoneNumberList>

我明白了:

<PhoneNumberList>213-512-7457213-512-7465</PhoneNumberList>

但我实际上想要:

<PhoneNumberList>213-512-7457, 213-512-7465</PhoneNumberList>

有人可以解释一下如何做到这一点吗?

Could someone shed some light on how to do this?

推荐答案

<PhoneNumberList>
{
    string-join($c//PhoneNumber, ", ")
}
</PhoneNumberList>

这篇关于XQuery:如何在 for 循环中正确追加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆