PL/SQL – selecting count on nodes in XML


To count the occurrence of a node in an XML-document using Oracle xml tools. 

This sample using a field in table M_DATA called XML_DATA of type XmlType.

the field would contain a XmlDocument structured like this.

<?xml version="1.0"?>
<document>
  <styles>
    <style>...
    </style>
  </styles>  
  <styles>
    <style>...
    </style>
  </styles>
</document>

To extract the number of occurrences of node Style

select  count(*) from TEST.M_DATA md, table ( xmlsequence(extract(MD.XML_DATA, '/catalog/styles/style'))) xml


One response to “PL/SQL – selecting count on nodes in XML”

Leave a Reply

Your email address will not be published. Required fields are marked *