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”?
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
//):produces the wanted result.