Hello there,
I’m trying to sort this xml file :
so that the Ntry elements are in descending order (the file is simplified, but I have + 200 Ntry elements).
In this case, I want the Ntry element containing 2635400405324088
before the
2635400405358333
Is it possible ? The result would still be a xElement variable.
I have already deserialized the file with the concerned activity.
Thank you in advance and best wishes.
Ludovic
Hello @ludovic.vetter try this linq approach
xml.Descendants("Stmt").ToList().ForEach(s=>s.ReplaceNodes(s.Elements().Where(e=>e.Name != "Ntry").Concat(s.Elements("Ntry").OrderByDescending(n=>(long)n.Element("AcctSvcrRef")))));
Cheers
Hello, you’re a machine though I have a lot of errors when doing that :
(sorry it’s in french )
Okayy I use LLM to translate and try this
xml.Descendants("Stmt").ToList().ForEach(Sub(stmt) stmt.ReplaceNodes(stmt.Elements().Where(Function(e) e.Name<>"Ntry").Concat(stmt.Elements("Ntry").OrderByDescending(Function(n) CLng(n.Element("AcctSvcrRef"))))) End Sub)
Cheers
ashokkarale
(Ashok Karale)
September 23, 2025, 1:55pm
5
@ludovic.vetter ,
May I know what’s the end goal here? As per my understanding this looks like a bank statement which we reconcile with some internal data.
If you have already deserialized the data, I would suggest to put it in a datatable or excel file and then do the sorting.
Anil_G
(Anil Gorthi)
September 23, 2025, 2:11pm
6
@ludovic.vetter
If you have already deserialized then sorting after that makes sense
it would order but that piece of xml will be ordered
cheers