Re: Extracting an XML fragment
MySql unfortunately doesn't have a function for extracting XML-fragments, only CDATA.
In some cases you may insert encapsulate a part of an XML-document with a CDATA section, so that EXTRACTVALUE will return tags and not only text.
Here's an example of how to insert an <![CDATA[ start tag and ]]> inside all occurrences of the tag <programDescription> that do not already have a CDATA section
UPDATE courses
SET xmldata = REPLACE(xmldata, '<programDescription>', '<programDescription>\n<![CDATA['),
xmldata = REPLACE(xmldata, '</programDescription>', ']]>\n</programDescription>')
WHERE xmldata NOT REGEXP '<programDescription>[[:space:]]{0,}<![[.left-square-bracket.]]CDATA'
;
Subject
Written By
Posted
Re: Extracting an XML fragment
December 07, 2008 05:45PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.