Sylvie,
There are many different ways you could approach this. Personally, I would use LINQ to parse the XML into an object. Please see my code below:
// Load the XML document into a stream.
StreamResourceInfo si = Application.GetResourceStream(new Uri("MyFile.xml", UriKind.Relative));
StreamReader sr = new StreamReader(si.Stream);
// Build an XDocument from the XML data.
// XDocument is in the System.Xml.Linq namespace.
// The LINQ query below, selects all of the lngOrderNumber and strText elements
// into an enumerable anonymous type called orders.
XDocument doc = XDocument.Parse(sr.ReadToEnd());
var orders = from a in doc.Descendants("Fields").Descendants("Field")
select new
{
OrderNumber = a.Element("lngOrderNumber").Value,
Text = a.Element("strText").Value
};
// Iterate over the enumerable collection
foreach(var order in orders)
{
System.Diagnostics.Debug.WriteLine("Order Number: " + order.OrderNumber);
System.Diagnostics.Debug.WriteLine("Text: " + order.Text);
}
If this has answered your question, please click on "Mark as Answer" on this post.
Thanks,
Page Brooks, MCSD, MCAD
PageBrooks.com | RSS Feed