How to parse XML ordered list like this
<ol>
<li>value1</li>
<li>value2</li>
<li>value3</li>
</ol>
into table like this (like it's visible in html):
Nr Value
----------- ------
1 value1
2 value2
3 value3
Here is the code for XML string:
declare @ol XML= '<ol><li>'+REPLACE('value1,value2,value3', ',', '</li><li>')+'</li></ol>'
select @ol
NB! Is it possible to parse "numbering" from XML without creating something like identity
column?
Small update: Following solutions provide right answer for simple example above:
But is it possible to get solution for this more tricky example:
DECLARE @ol XML
SET @ol=
'<ol type="i" start="3">
<li>value1</li>
<li>value2</li>
<li>value3</li>
</ol>';
Estimated result:
Nr Value
---- -------
iii value1
iv value2
v value3
?