XQuery:获取多个属性值

时间:2013-05-14 08:44:44

标签: xpath xquery

所以我试图访问以下国家代码,但没有运气:

  <river id="river-Rhone" country="F CH">
  <name>Rhone</name>
  <located country="F" />
  <located country="CH"/>
  </river>

有没有办法让他们?我尝试通过索引访问它们但没有任何作用。任何帮助表示赞赏!

2 个答案:

答案 0 :(得分:0)

您似乎希望获得/定位/ @ country作为输出:

<强> XQUERY:

let $XML := <river id="river-Rhone" country="F CH">
              <name>Rhone</name>
              <located country="F" />
              <located country="CH"/>
             </river>
for $country in $XML//located/@country
return 
 <p>{data($country)}</p>

<强>输出:

<p>F</p>
<p>CH</p>

答案 1 :(得分:0)

所以@Navin Rawat建议你可以这样做:

tokenize($river/@country, '\s+')