• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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 ]
reply
    Bookmark Topic Watch Topic
  • New Topic