I have some text in a C# [WebMethod] as such:
string myText = "<item>One</item><item>Two</item><item>Three</item>";
I wish to split them into an array (myArray) with the following string on each of the indices:
myArray[0] = <item>One</item>
myArray[1] = <item>Two</item>
myArray[2] = <item>Three</item>
This is how I am trying to achieve that:
string[] myArray = Regex.Split(myText, "</item><item>");
The problem in this is, I get this undesirable result:
myArray[0] = <item>One
myArray[1] = Two
myArray[2] = Three</item>
Which clearly looks like it is excluding the criteria I used to split myText, from the resultant array elements.
I have also tried:
string[] myArray = Regex.Split(myText, "$1" + "</item><item>" + "$2");
This one doesn't even split the text. I am open to suggestions on any different method to handle this too.
Additional info per suggestions in comments
I will be storing these 'items' as nodes in a BaseX DB. The problem I had with BaseX is that the 'insert into node...' XQUERY for BaseX is only good for inserting one node/item (as far as I know). So my plan here is to store all the items in an array and loop through each of them to run a BaseX XQUERY for each node/item separately. I hope I was clear :P