我想只获得数量大于一的元素。我应该使用什么?Tokenizer不工作我猜这里......
<games>
<game>
<Motion>False</Motion>
<Platform>Playstation3,XBox, typer</Platform>
</game>
<game>
<Motion>False</Motion>
<Platform>Playstation3</Platform>
</game>
</games>
答案 0 :(得分:0)
您可以使用contains()功能:
doc("games.xml")//game[contains(Platform, ",")]
编辑:您发布的查询与您的XML标记不符。尝试类似:
for $z in doc("videogames.xml")//game[contains(Platform, ",")]
return
<Platform>{$z/Motion}</Platform>
答案 1 :(得分:0)
我想只获得那些元素 哪个数字大于一。什么 我应该使用吗?Tokenizer不工作 我猜这里......
我的猜测是你只想使用可用于多个平台的游戏。
使用此测试:
/*/game[tokenize(Platform, ',')[2]]
所以,这个简单的XQuery :
for $g in /*/game[tokenize(Platform, ',')[2]]
return $g
应用于提供的XML文档:
<games>
<game>
<Motion>False</Motion>
<Platform>Playstation3,XBox, typer</Platform>
</game>
<game>
<Motion>False</Motion>
<Platform>Playstation3</Platform>
</game>
</games>
<强>返回强>:
<game>
<Motion>False</Motion>
<Platform>Playstation3,XBox, typer</Platform>
</game>