This post originated from an RSS feed registered with Ruby Buzz
by Daniel Berger.
Original Post: Oracle and XML - one step forward, one step back
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
A while back I was griping about Oracle's string handling functions for use with XML. Well, it turns out Oracle 9 and later has some nice XML handling routines using the XMLType data type. For example, if you want to select the value for a given element, you can use extract() plus xpath:
select extract(xmltype('<person><name>Dan</name></person>'), '/person/name/text()') from dual;
Dan
There are a couple other handy methods. The one I wanted to work the most was updateXML(). With that, you can update a given element on the fly:
The problem, as you may have noticed from the output, is that updateXML() auto-formats the result. I don't want that. I just want a single string of text. Unfortunately, I still haven't found a way around this.
Yet another issue is that neither Ruby nor Perl have drivers that support the XMLType data type.