Reputation: 49
Hello here is my problem: I have a xml contained within a variable that is like this:
<channel>
<available>yes</available>
<label>CNN</label>
</channel>
<channel>
<available>yes</available>
<label>BBC</label>
</channel>
....
i want to use xquery to get the value using conditions such as below:
For Channels.Channel
where Channel/availability = yes
And Channels.Channel/Label = «CNN»
Return EXIST(Channels.Channel/Id)
My question is: How do I execute xquery to return this ID value and stores the result within a javascript variable that I can use later on and pass to other systems. If its not possible please let me know how would you do to take a variable within this xml
Thanks.
Upvotes: 0
Views: 469
Reputation: 11771
I'm a bit confused by your example, but taking at face value I think this would return all of the ID values.
for $channel in $channels/channel
where ($channel/available = 'yes' and $channels/channel/label = 'CNN')
return $channel/id
To communicate with other systems, you could create a JSON webservice and return this to your JavaScript.
Upvotes: 0