I have a xml which conatins the basic match data now I need to reorder it and update the id's of that node.
Here is my xml -
Match>
Now i want to update the Sequence in uniform order. so what i want is look like this -
Match>
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jul 23, 2014, 4:11 AM
hi,
try following code
var xml = XElement.Load("XMLFile1.xml");
var ordered = from r in xml.Descendants("Element")
select r;
int seqNo = 1;
foreach (var p in ordered)
{
p.Attribute("Sequence").Value = seqNo.ToString();
seqNo += 1;
}
xml.Save("XMLFile2.xml");
hope this will help you.