Advertisement
ivandrofly

Sorting Customers Orders XML (XDocument)

Dec 18th, 2013
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.48 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System;
  3. using System.Linq;
  4.  
  5. var thisElemnt = XElement.Load(path1);
  6.             foreach (XElement cust in input.Root.Elements("customer"))
  7.             {
  8.                 cust.Element("orders").ReplaceWith(new XElement("orders",
  9.                     from n in cust.Element("orders").Elements("order")
  10.                     orderby Convert.ToInt32(n.Element("id").Value)
  11.                     select n));
  12.  
  13.             }
  14.             input.Save(path1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement