I am not sure if this is the best way to do it, but it does get the result you are looking for using linq with xml:
var query = new XElement("Students",
from node0 in Query.Split('|')[0].Split('=')[1].Split(',').Select((item, index) => new { item, index })
join node1 in Query.Split('|')[1].Split('=')[1].Split(',').Select((item, index) => new { item, index })
on node0.index equals node1.index
join node2 in Query.Split('|')[2].Split('=')[1].Split(',').Select((item, index) => new { item, index })
on node0.index equals node2.index
select
new XElement("stud",
new XElement(Query.Split('|')[0].Split('=')[0], node0.item),
new XElement(Query.Split('|')[1].Split('=')[0], node1.item),
new XElement(Query.Split('|')[2].Split('=')[0], node2.item)
)
);
Basically modified the structure to loop via the comma delimited Values rather than the Names (ID, class, name).
The tricky bit is getting the lists to join by the list index.
Here is link if you are interested:
http://techbrij.com/linq-combine-multiple-lists-parallel-c[
^]
var Query = "ID=265465,265466,265467,265468" + "|" +
"class=6,6,6,6" + "|" +
"grade=A,B,C,D" + "|" +
"name=ABC,DEF,GHI,JKL";
var query = new XElement("Students",
from node0 in Query.Split('|')[0].Split('=')[1].Split(',').Select((item, index) => new { item, index })
select
new XElement("stud",
from n in Query.Split('|')
select new XElement(n.Split('=')[0], n.Split('=')[1].Split(',')[node0.index].Trim())
)
);