RE: extracting xml tag name

  • From: "Shay Toder" <shayt@xxxxxxxxxxxx>
  • To: "Christian Antognini" <Christian.Antognini@xxxxxxxxxxxx>
  • Date: Tue, 6 Dec 2005 08:57:00 +0200

Thank you very much,
It works like a charm.

Another option is to use this line (if you exactly in the place, if not, your 
line is better) - 
  VALUE (e).getrootelement() AS tag2

Like in this example -
SELECT EXTRACT (VALUE (e), '/').getstringval () AS xml
     , EXTRACTVALUE (VALUE (e), '/') AS VALUE
     , XMLTYPE (EXTRACT (VALUE (e), '/').getstringval ()).getrootelement() AS 
tag
     , VALUE (e).getrootelement() AS tag2
  FROM TABLE(XMLSEQUENCE(EXTRACT(XMLTYPE(
     '<A>
        <B>2</B>
        <C>3</C>
        <D>4</D>
     </A>')
       , '/A/*'))) e

thanks,
Shay


 -----Original Message-----
From:   Christian Antognini [mailto:Christian.Antognini@xxxxxxxxxxxx] 
Sent:   Monday, December 05, 2005 7:58 PM
To:     Shay Toder
Cc:     oracle-l@xxxxxxxxxxxxx
Subject:        RE: extracting xml tag name

Shay

>how can i get the NAME of the XML node,

In XPath the fuction name() should be used for that. Unfortunately you cannot 
use it with extract()...

Here a workaround:

SQL> SELECT XMLType(extract(value(e),'/').getstringval()).getRootElement() AS 
xml
  2  FROM TABLE (XMLSEQUENCE (EXTRACT (
  3       XMLTYPE ('<A>
  4                    <B>2</B>
  5                    <C>3</C>
  6                    <D>4</D>
  7                </A>'
  8            ), '/A/*'))) e;

XML
---------------------------------------------------------------------------------
B
C
D


HTH
Chris
--
//www.freelists.org/webpage/oracle-l


Other related posts: