'' Load the XML document to be summerized into memory Dim xdoc As XDocument = XDocument.Load(Application.StartupPath + "\AOP5.xml") '' Group the TableA nodes by AGD4 then get a string containing all the Country values order the Country values '' and return the groupings and summary string so that it can be inserted into the XML Dim results = (From n In xdoc.Descendants("AOP5C") Where n.Element("AGD4").Value <> "NA" Group n By n.Element("AGD4").Value Into agd4Group = Group Let sum = agd4Group.Select(Function(g) g.Element("COUNTRY").Value).OrderBy(Function(g) g).ToArray() _ From g In agd4Group _ Let summary = String.Join(",", sum) _ Select g, summary).ToList() '' Update the Summary node with the value of the summary string. results.ForEach(Sub(m) m.g.Element("CANMN").Value = m.summary) '' Save the document. xdoc.Save(Application.StartupPath + "\AOP5.xml")
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.