Xquery 争论中的怀疑

Xquery 争论中的怀疑,xquery,Xquery,我只想得到数字大于1的元素。我应该用什么?标记器不起作用我想这里 <games> <game> <Motion>False</Motion> <Platform>Playstation3,XBox, typer</Platform> </game> <game> <Motion>False&l

我只想得到数字大于1的元素。我应该用什么?标记器不起作用我想这里

<games>  
    <game>  
        <Motion>False</Motion>  
        <Platform>Playstation3,XBox, typer</Platform>  
    </game>  
    <game>  
         <Motion>False</Motion>  
        <Platform>Playstation3</Platform>  
    </game>  
</games> 

假的
Playstation3、XBox、打字机
假的
游戏站3
您可以使用以下功能:

doc("games.xml")//game[contains(Platform, ",")]
编辑:您发布的查询与XML标记不匹配。尝试以下方法:

for $z in doc("videogames.xml")//game[contains(Platform, ",")]
return
<Platform>{$z/Motion}</Platform>
用于doc中的$z(“videogames.xml”)//游戏[contains(Platform,”)]
返回
{$z/运动}
我只想把那些元素放进去 哪个数字大于一。什么 我应该使用吗?标记器不工作 我想在这里

<games>  
    <game>  
        <Motion>False</Motion>  
        <Platform>Playstation3,XBox, typer</Platform>  
    </game>  
    <game>  
         <Motion>False</Motion>  
        <Platform>Playstation3</Platform>  
    </game>  
</games> 
我的猜测是,您只希望使用可用于多个平台的游戏

使用此测试

/*/game[tokenize(Platform, ',')[2]]
for $g in /*/game[tokenize(Platform, ',')[2]]
  return $g
<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>
那么,这个简单的XQuery

/*/game[tokenize(Platform, ',')[2]]
for $g in /*/game[tokenize(Platform, ',')[2]]
  return $g
<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>
应用于提供的XML文档时

/*/game[tokenize(Platform, ',')[2]]
for $g in /*/game[tokenize(Platform, ',')[2]]
  return $g
<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>

假的
Playstation3、XBox、打字机
假的
游戏站3
返回

/*/game[tokenize(Platform, ',')[2]]
for $g in /*/game[tokenize(Platform, ',')[2]]
  return $g
<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>

假的
Playstation3、XBox、打字机

我应该把大于条件放在哪里?@user507087,对不起,我一定是误解了。我以为您希望
元素具有多个平台,即其
元素包含逗号字符。那么你到底想要什么呢?:)在我在问题中给出的上述输入中,当我运行查询时,我应该只得到游戏中具有多个平台的上层元素——playstation3、Xbox和typer。它应该丢弃另一个,因为在这种情况下平台的数量仅为1。@user507087,所以我的解决方案应该可以工作,因为它只返回
元素,这些元素的
元素包含
字符,这意味着存在多个平台。它没有显示任何内容…没有输出。我返回游戏/