Below is the XML File -
<Title t="1">
<Book sub="Computers"/>
<Book sub="Engg."/>
</Title>
<Title t="2">
<Book sub="Computers"/>
</Title>
<Title t="1">
<Book sub="Computers"/>
<Book sub="Engg."/>
<Book sub="Medical"/>
</Title>
What will be the XQuery to count the occurrences of "Computers"?
计算将'Computers'
作为值的所有sub
属性:
count(//@sub[. = 'Computers'])
Assuming that the provided XML fragment is wrapped in a single top element so that this becomes a well-formed XML document, then the following XPath expression (not using //
):
count(/*/*/*/@sub[. = 'Computers'])
produces the wanted result.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.