XQuery Expression learning

XML数据处理与解析技巧
本文深入探讨了如何使用XML语法进行数据检索、过滤、排序和整合,包括使用for、where、order和return语句进行复杂操作,以及如何直接获取数据和使用内置函数。文章还详细解释了比较运算符的使用,提供了XML数据处理的基础语法规则和注意事项。
部署运行你感兴趣的模型镜像

open the file: doc("xxx.xml")

 

doc("xxx.xml")/bookstore/book[conditon clause]

 

for, where, order, return

 

doc("xxx.xml")/bookstore/book[price>20]/title

=

for $x in doc("xxx.xml")/bookstore/book

where $x/price>20

order by $x/title

return $x/title

 

integrate with html tags

<ul>

for $x in doc("xxx.xml")/bookstore/book/title

oder by $x

return <li>($x)</li>

</ul> 

 

get the data directly use the data() function

ex:

<ul>

for $x in doc("xxx.xml")/bookstore/book/title

return <li>(data|($x))</li>

</ul>

 

basic syntax rules

comment: (:  I am comment :)

"if-then-else": 

for $x in doc("xxx.xml")/bookstore/book

return if ($x/@attribute="hey")

then <child>(data($x/title))</child>

else <adult>(data($x/title))<adult>

comparisons:

one group: =, !=, <, <=, >, >=

another group: eq, ne, lt, le, gt, ge

what's the difference? see the follow two examples

$bookstore//book/@q > 20   --> if any items fulfill the condition,  then return true

$bookstore//book/@q lt 20   --> only one item fulfill the condition, then return true

 

use function

default functions: upper-case, substring, data, and so on...

custom function:

declare function prefix:function_name($parameter AS datatype)

AS returnDataType{

  ...

}

 

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值