Parsing XElement

shaneape

New Member
I am newbie to LINQ/XML. I just learned that Language integrated queries can be used for parsing xml. I am trying to parse the following XML structure and I need help==================================\[code\]<config><params> <tp name="abc">yes</tp> <tp name="aee">no</tp> <tp name="bbc">no</tp> <tp name="ccb">yes</tp></params><nits> <tn name="kjh"> <min>44</min> <max>98</max> </tn> <tn name="klm"> <min>55</min> <max>88</max> </tn> <tn name="hhh"> <min>44</min> <max>98</max> </tn></nits><params> <tp name="lml">no</tp> <tp name="rre">yes</tp> <tp name="rst">no</tp> <tp name="wee">yes</tp></params><nits> <tn name="adf"> <min>44</min> <max>98</max> </tn> <tn name="ddd"> <min>42</min> <max>92</max> </tn> <tn name="kjj"> <min>92</min> <max>98</max> </tn></nits></config>\[/code\]==================================Output needed : My objective is to show the above data as key value pairs by the category in a text file or a data grid etc.\[code\]<Params>abc : yesaee : nobbc : yes............<nits>kjh: 44 , 98klm: 55 , 88......kjj: 92 , 98ddd: 42 , 92...\[/code\]The code I have written so far is,\[code\]static void QueryTheData(XDocument doc) { try { var a = doc.Descendants("config").Elements("params"); var b = doc.Descendants("config").Elements("nits"); var c = doc.Elements("tp"); var d = doc.Elements("tn"); /* to do : parse the elements into key value pairs */ /* Need hint or help to proceed to get key value pairs from xml data } catch(Exception e) { .... } }\[/code\]ANy good pointers for beginner's LINQ/XML C# is also needed.thanks in advance,ak
 
Back
Top