0

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

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

有没有办法得到它们?我尝试通过索引访问它们,但没有任何效果。任何帮助表示赞赏!

4

2 回答 2

1

因此@Navin Rawat 建议您可以执行以下操作:

tokenize($river/@country, '\s+')
于 2018-04-02T20:25:20.647 回答
0

看来您想获得 /located/@country 作为输出:

查询:

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>
于 2013-05-14T08:50:16.980 回答