While trying to process and obtain data from an XML document, I want to obtain a number of records using a single FLWOR expression– I am doing this by using the ‘let’ clause to obtain the data– so I have a number of rows of data.
Eg.
<div id="main">
<p> Text #1</p>
<p> Text #2</p>
<p> Text #3</p>
<p> Text #4</p>
</div>
Now, I understand how to get the 4 ‘p’ elements — however I would like to also assign a sequence number to each line — viz. I want to obtain the text this way–
<data>Text #1</data><sequence> Sequence #1</sequence>
<data>Text #2</data><sequence> Sequence #2</sequence>
<data>Text #3</data><sequence> Sequence #3</sequence>
<data>Text #4</data><sequence> Sequence #4</sequence>
There sure is a more elegant way than doing it like this…. but it works: