This week's book giveaway is in the Design and Architecture forum.
We're giving away four copies of Communication Patterns: A Guide for Developers and Architects and have Jacqui Read on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

count xmltype node

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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="11.2.0.0.1">

<report_id><![CDATA[/orarep/sqltune/auto_summary?section=task_stats]]></report_i
d>
<summary>
<statistics>
<task_stats>
<counts>

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

<test_id>5</test_id>
<test_id>51</tets_id>
</top_profiles>

</task_stats>
</statistics>
</summary>
</report>


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;



Thanks,
[ August 26, 2008: Message edited by: Steve Jiang ]
 
Anderson gave himself the promotion. So I gave myself this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic