I have the following XML:
<prescriptions>
<prescription id="1" amka="1">
<status>closed</status>
<doctor_info>
<amka>111111</amka>
<doc_code> 123</doc_code>
<name> chris</name>
<surname>st</surname>
<specialization>path</specialization>
<hospital>401</hospital>
</doctor_info>
<patient_info>
<amka>1</amka>
<genre>man</genre>
<name>elton </name>
<surname>kev</surname>
<age>28</age>
<adress>aaa123</adress>
<home_phone>210</home_phone>
<cell_phone>69</cell_phone>
<email>[email protected]</email>
<insurance>diom</insurance>
</patient_info>
<main_prescription>
<type>eee</type>
<epanalipseis>2</epanalipseis>
<date>21/1/2012</date>
<comms>blablabla</comms>
<diagnosh>kkkk</diagnosh>
<drug1>
<onoma>prezza</onoma>
<drastikh_ousia>llll</drastikh_ousia>
<posotita>12</posotita>
<dosologia>
<arithmos_hapion>5</arithmos_hapion>
<ores>2</ores>
<hmeres>21</hmeres>
</dosologia>
<simetoxi>25%</simetoxi>
<tropos_xorigisis>ass</tropos_xorigisis>
<cost>100</cost>
</drug1>
<drug2>
<onoma>prezza</onoma>
<drastikh_ousia>llll</drastikh_ousia>
<posotita>12</posotita>
<dosologia>
<arithmos_hapion>5</arithmos_hapion>
<ores>2</ores>
<hmeres>21</hmeres>
</dosologia>
<simetoxi>25%</simetoxi>
<tropos_xorigisis>ass</tropos_xorigisis>
<cost>100</cost>
</drug2>
<drug3>
<onoma>prezza</onoma>
<drastikh_ousia>llll</drastikh_ousia>
<posotita>12</posotita>
<dosologia>
<arithmos_hapion>5</arithmos_hapion>
<ores>2</ores>
<hmeres>21</hmeres>
</dosologia>
<simetoxi>25%</simetoxi>
<tropos_xorigisis>ass</tropos_xorigisis>
<cost>100</cost>
</drug3>
<total_cost>100</total_cost>
<prospou>nosokomeio</prospou>
<drug_comms>ablablabla</drug_comms>
</main_prescription>
</prescription>
</prescriptions>
In <main_prescription> node I have 3 nodes for drugs: <drug1> , <drug2> and <drug3>.
Is there a way to count how many nodes name <drug...> are there using XQuery?
I am using the XQuery below but it is wrong:
select prescriptions.query('count(/prescriptions/prescription/main_prescription/drug[*])') as one1 from prescription