• Post Reply Bookmark Topic Watch Topic
  • New Topic

count xmltype node  RSS feed

Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to count the number of node in a varchar2 variable.

The xml data like below, I hope to count how many node test_id in the xml file. In this xml data, we have 2 test_id (as 5 and 51). so I need to get 2 as result in a PL/SQL package.

I looked extract and extractvalue

<report db_version="">


<stat name="executions">7</stat>



The blow query returns 551 as result, Do you have any suggestions to sepearte the data and get the count for the node number?

select nvl(XMLType(:rept).extract('//test_id/').getstringval(), '(NULL)') into :te from dual;

[ August 26, 2008: Message edited by: Steve Jiang ]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!