troubleshooting Question

Help with passing values to dataelement based on partial string

Avatar of vcharles
vcharles asked on
.NET ProgrammingVisual Basic.NET
6 Comments1 Solution176 ViewsLast Modified:

How d I modify the line below to look for part of AGD4, for example AGD4 contains data in the following format (XXXX-XX-XXXX) and I need to look for the mIddle value (-XX-) instead of the entire value of AGD4.

Group n By n.Element("AGD4").Value.substring (??)  Into agd4Group = Group

  '' 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")
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”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.

-Mike Kapnisakis, Warner Bros