Sunday, January 13, 2013

Delimited String Split - XML Parsing Method

I'd blogged previously on a string splitting function which splits up CSV onto individual values
http://visakhm.blogspot.in/2010/02/parsing-delimited-string.html
The same scenario can be handled by means of XML functions too. This blog provides a method of splitting up of delimited string into its component words by using XML functions.



The output would be as follows



wrd
-------
This
is
a
long
sentence
which
is
to
be
split
into
component
words


The above code casts the string to XML value by forming XML nodes out of the delimiters and then applies nodes() function to parse out the data from the nodes to get the component words.