Im new to XQuery and are trying to learn how to use it with BaseX.
I have this xml containing multiple elements of program:
<program id="4565">
<name>Musiken i P3</name>
<url>http://sverigesradio.se/sida/default.aspx?programid=4565</url>
<editor>Anna-Karin Larsson</editor>
<channel>164</channel>
<category>5</category>
</program>
So far i have understod that i can get the distinct values of for example editor like such:
let $vals := $sr/sr/programs/program/editor
let $uniqe-items := distinct-values($vals)
for $vals in $uniqe-items
order by $vals
return <li>{string($vals)}</li>
However when i do this I only get the editors name and I can't understand how i also check something like this:
let $vals := $sr/sr/programs/program/editor
let $uniqe-items := distinct-values($vals)
for $vals in $uniqe-items
where $vals/channel = "132"
order by $vals
return <li>{string($vals)}</li>
I was thinking that i could do something like $vals/../channel to get back to the channel attribute but that doesn't seem to be the case.
Anna-Karin Larssonhave the channel 132, how should the result look like? It could help if you added a full input example (possibly minimized, i.e. without elements that do not contribute to the understanding, but with more than 1 program element) and the expected result to your question. Thanks in advance. - Christian Grün