0
votes

So I'm trying to access the country codes of the following, but with no luck:

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

Is there a way to get them? I tried access them by index but nothing works. Any help is appreciated!

2

2 Answers

1
votes

so as @Navin Rawat has suggested you can do something like:

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

It seems you want to get /located/@country as output:

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>

OUTPUT:

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