Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: extracting xml tag name
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_at_trivadis.com] Sent: Monday, December 05, 2005 7:58 PM To: Shay Toder Cc: oracle-l_at_freelists.org 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
HTH
Chris
-- http://www.freelists.org/webpage/oracle-lReceived on Tue Dec 06 2005 - 01:00:43 CST
![]() |
![]() |