Reading attributes in an XML file

kensimms2000

New Member
I am trying to read a file that looks like this:\[code\]<tasks> <task name="Project Management" mode="Automatic" start="07/01/2012 00:00" duration="21" id="954471332"></task> <task name="Conception/Approval" mode="Automatic" start="07/01/2012 00:00" duration="6" percentComplete="1" id="1905425539"></task> <task name="Define Initial Scope" start="07/04/2012 00:00" finish="07/18/2012 00:00" percentComplete="0.31" id="1154759651"></task></tasks>\[/code\]I only want the values of \[code\]name\[/code\], \[code\]start\[/code\], and \[code\]finish\[/code\] or \[code\]duration\[/code\], whichever exists. This is what I have so far:\[code\]XElement allData = http://stackoverflow.com/questions/11419888/XElement.Load(dlg.FileName);if (allData != null){ IEnumerable<XElement> tasks = allData.Descendants("task"); foreach (XElement task in tasks) { }}\[/code\]I'm sure I have to use the Attribute method but I'm not sure how to use it or the syntax.
 
Back
Top