<results> <result> <item> <name>COLL_NAME</name> <value>ID</value> </item> <item> <name>DESCRIPTION</name> <value>Collumn ID</value> </item> </result> <result> <item> <name>COLL_NAME</name> <value>UNAME</value> </item> <item> <name>DESCRIPTION</name> <value>User Name</value> </item> </result> <result> <item> <name>COLL_NAME</name> <value>FNAME</value> </item> <item> <name>DESCRIPTION</name> <value>First Name</value> </item> </result> ... </results>
and I would like to convert this into a Manageable object such as a dictonary where each result would have the key equal to item[0].value, and the value equal to item[1],value
But LINQ totally confuses me and I have no idea how to get from point A to point B or even some midpoint that I can work from.
truth to be known I am not even sure how to get the second item from the result using X-DOM. I suppose I have to do nested loop foreach-reuslt and then foreach-item... There has got to be an easier way... Any hints?
SO far I can't even get this to work:
Dictionary<string, string> mannagable = new Dictionary<string, string>(10);
XDocument resultsDoc = Xdocument.Parse(result);
foreach (XElement r in resultsDoc.Descendants("result")) {
foreach(XElement item in r.Elements("item") ){
Console.WriteLine(item);
}
}
All of the LINQ to XML examples I find have these ultra-simple xml files... I just need to get my head wrapped arround how this might work with a real life XML file.

New Topic/Question
Reply




MultiQuote





|