Link to home
Start Free TrialLog in
Avatar of spanout
spanout

asked on

C# XML Descendants Query

HI

I hope someone can help me...


I am trying to analyse an XML doc with the following structure:

<?xml version="1.0"?>
-<Sessions>
 -<Session requestId="87ADEDDFF28D4C26FE4F7B584599126D">
<URL>www.xyz.com</URL>
-<Issues>-
<Issue id="c09c9dd6-3843-4885-9aae-639f9dec93d9">
<VID>4727</VID>
</Issue>
<Issue id="a29c9dd6-3843-4885-9aae-639f9dec93d9">
<VID>4728</VID>
</Issue>
</Issues>
</Session>
</Sessions>


So there are multiple sessions, each have a URL and multiple issues. What I need is to get all the VID values along with the URL in parent section.


Before the schema changed (URL was at same level as VID, I had code that worked:

            var issues = from issue in xmlDoc.Descendants("Issue")
                         select new
                         {
                             VID = issue.Element("VID").Value,
                             URL = issue.Element("URL").Value




                         };

            foreach (var issue in issues)
            {

                var instances = from element in Instances
                                where (element.id == issue.VID)
                                select element;


.......


But I cannot get my head around this stuff and any help is creatly appreciated.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of spanout
spanout

ASKER

Perfect, brilliant so simple... thank you
Avatar of spanout

ASKER

Brilliant and so simple... thanks
Not a problem spaout, glad I was able to help.