I am trying to create a dynamic xelement.
I want the output in Xelement as :
<text> text1 </text>
<text> text2 </text>
So, I wrote code as :
string[] arr = new string[2];
arr[0] = "text1";
arr[1] = "text2";
XElement xElement1;
XElement xElement12 = new XElement(string.Empty);
for (int i=0;i<arr.Length;i++)
{
xElement1 = new XElement("text");
xElement1.Add(arr[i].ToString());
xElement12.Add(xElement1);
}
But, with this code, I get output as :
<text>
<text> text1 </text>
<text> text2 </text>
</text>
Can anyone please let me know.I want this data in Xelement and there can be n number of data in the array.