In: Computer Science
Write an XQUERY to display the information for all students who are not Malaysians or older than 25
<root>
<students>
<element>
<ID>100345</ID>
<Nationality>USA</Nationality>
<Program>ICT</Program>
<age>23</age>
<name>John</name>
</element>
<element>
<ID>100876</ID>
<Nationality>MALAYSIA</Nationality>
<Program>CS</Program>
<age>28</age>
<name>Awang</name>
</element>
<element>
<ID>100257</ID>
<Nationality>AUSTRALIA</Nationality>
<age>25</age>
<name>Alex</name>
</element>
</students>
</root>
Hello ,Please find below answer. If you have ny queries you can tell me.
Answer : root/students/element[Nationality!='MALAYSIA' or age>25]
Output :
<?xml version="1.0" encoding="UTF-8"?>
<element>
<ID>100345</ID>
<Nationality>USA</Nationality>
<Program>ICT</Program>
<age>23</age>
<name>John</name>
</element>
<element>
<ID>100876</ID>
<Nationality>MALAYSIA</Nationality>
<Program>CS</Program>
<age>28</age>
<name>Awang</name>
</element>
<element>
<ID>100257</ID>
<Nationality>AUSTRALIA</Nationality>
<age>25</age>
<name>Alex</name>
</element>
The above query will display all 3 student information because every student have either age > 25 or nationality is not malaysia.
Thank you.