Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XMLTYPE Text Node Extraction 1

Status
Not open for further replies.

MikeAJ

Programmer
May 22, 2002
108
US
Is it possible to separate the results of an XMLType.extract where many nodes match the XPATH?

For example:
Code:
DECLARE
   v_XML XMLTYPE := XMLTYPE('<root><text>one</text><text>two</text><text>three</text></root>');
BEGIN
   dbms_output.put_line(v_XML.extract('//text/text()').getstringval());
END;

returns: onetwothree

Is it possible to throw a delimited between each result so it returns: one|two|three

Thanks!
 
The following code will produce

DECLARE
v_num xmltype;
val varchar2(100);
v_XML XMLTYPE := XMLTYPE('<root><text>one</text><text>two</text><text>three</text></root>');
BEGIN
v_num := v_xml.extract('//root/text');
val := v_num.getstringval();
dbms_output.put_line(val);
END;

will produce

<text>one</text>
<text>two</text>
<text>three</text>

Hope this helps.

 
Thanks! That pointed me in the right direction. Went in a slightly different direction, I'm using the position condition, but your post definitely helped!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top