所以我试图访问以下国家代码,但没有运气:
<river id="river-Rhone" country="F CH">
<name>Rhone</name>
<located country="F" />
<located country="CH"/>
</river>
有没有办法得到它们?我尝试通过索引访问它们,但没有任何效果。任何帮助表示赞赏!
因此@Navin Rawat 建议您可以执行以下操作:
tokenize($river/@country, '\s+')
看来您想获得 /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>