Geeks With Blogs
Calin Tatar C#.NET, VB.NET, WPF, SILVERLIGHT, SQL, WSS, MOSS

I'm writing here an example about how to read XMLs that contains hierarchichal data, not only with one level of child nodes. So, I'm about to threat this problem here.

First, I'll define a sample XML hierarchy. The XML contains a list of Headers, each one containing a list of Details.

Now, let's create some simple model classes.

 Now, to read the XML data into this hierarchy of objects, I'm gonna create one method for each level of the hierarchy (GetHeaders - will return all the Headers, GetDetails(header) - will return a list of Detail's for one Header.

Basically, a method will return a list of childrens based on the parent node.

 

Posted on Saturday, May 16, 2009 7:03 AM Linq to XML | Back to top


Comments on this post: Retrieving the object hierarchy from an XML with Linq to XML

# re: Retrieving the object hierarchy from an XML with Linq to XML
Requesting Gravatar...
Simple and to the point. Thanks!
Left by Chris Stevenson on Mar 19, 2011 4:38 PM

# re: Retrieving the object hierarchy from an XML with Linq to XML
Requesting Gravatar...
Can you please give your source code
Left by Wina on Oct 08, 2013 8:29 AM

Your comment:
 (will show your gravatar)


Copyright © CalinTatar | Powered by: GeeksWithBlogs.net