MySQL Forums
Forum List  »  Connector/Node.js

Re: Extracting an XML fragment
Posted by: Harald Groven
Date: December 07, 2008 05:45PM

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'
;

Options: ReplyQuote


Subject
Written By
Posted
October 24, 2008 02:46PM
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.