Calin Tatar

C#.NET, VB.NET, WPF, SILVERLIGHT, SQL, WSS, MOSS
posts - 5, comments - 27, trackbacks - 0

My Links

News

Archives

Post Categories

C#.NET

Links

VB.NET

Retrieving the object hierarchy from an XML with Linq to XML

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.

 

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted on Saturday, May 16, 2009 7:03 AM | Filed Under [ Linq to XML ]

Feedback

Gravatar

# re: Retrieving the object hierarchy from an XML with Linq to XML

Simple and to the point. Thanks!
3/19/2011 4:38 PM | Chris Stevenson
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: