Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to Count Nodes in an XML Document?

Joe RNov 13 2019 — edited Nov 13 2019

Version: Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production

Hello,

I have an XML document that I was looking to count the number of nodes. This would be used as part of processing validation.

I have a job process that obtains an XML document from another company through web services in PL/SQL using APEX API's and there were 40 records in the document, however only 5 were processed.

The thought behind the failure was a communication time out as I had received 2 error notices running manual processes with the same company that had a time out issue, though no error notices were returned from the job.

So the idea was to count the number of nodes in this XML document and then get a final count of records processed and if they don't match send an alert.

The XML document looks like this (condensed for posting):

<ResultIDs>

    <ResultID>1884162</ResultID>

    <ResultID>1884179</ResultID>

    <ResultID>1884196</ResultID>

    <ResultID>1884243</ResultID>

    <ResultID>1884279</ResultID>

</ResultIDs>

I'd like to count the number of the <ResultID> nodes.

I searched the forum and found posts that were several years old and with the newer version of Oracle I thought there may be an "updated" approach.

I hope I've explained this. If not, please let me know.

Thanks,

Joe

This post has been answered by Solomon Yakobson on Nov 13 2019
Jump to Answer
Comments
Post Details
Added on Nov 13 2019
2 comments
4,681 views