【发布时间】:2012-01-25 09:37:51
【问题描述】:
我有以下 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>aaa@aaa.com</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>
在<main_prescription> 节点中,我有 3 个药物节点:<drug1> , <drug2> 和 <drug3>。
有没有一种方法可以使用 XQuery 来计算有多少名为 <drug...> 的节点?
我正在使用下面的 XQuery 但它是错误的:
select prescriptions.query('count(/prescriptions/prescription/main_prescription/drug[*])') as one1 from prescription
【问题讨论】: