<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Linq to XML</title>
        <link>http://geekswithblogs.net/CalinTatar/category/10095.aspx</link>
        <description>Linq to XML</description>
        <language>en-US</language>
        <copyright>CalinTatar</copyright>
        <managingEditor>tatar_calin@yahoo.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Retrieving the object hierarchy from an XML with Linq to XML</title>
            <link>http://geekswithblogs.net/CalinTatar/archive/2009/05/16/retrieving-the-object-hierarchy-from-an-xml-with-linq-to.aspx</link>
            <description>&lt;p&gt;&lt;font size="2"&gt;I'm writing here an example about how to read XMLs that contains &lt;font face="Arial"&gt;hierarchichal data, not only with one level of child nodes. So, I'm about to threat this problem here.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;First, I'll define a sample XML hierarchy. The XML contains a list of Headers, each one containing a list of Details.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;img height="416" alt="" width="427" src="/images/geekswithblogs_net/CalinTatar/Data.jpg" /&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Now, let's create some simple model classes. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;img height="446" alt="" width="391" src="/images/geekswithblogs_net/CalinTatar/Header.jpg" /&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;img height="307" alt="" width="313" src="/images/geekswithblogs_net/CalinTatar/Detail.jpg" /&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt; Now, to read the XML data into this hierarchy of objects, I'm gonna create one method for each level of the hierarchy (&lt;strong&gt;GetHeaders - &lt;/strong&gt;will return all the Headers, &lt;strong&gt;GetDetails(header)&lt;/strong&gt; - will return a list of Detail's for one Header. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Basically, a method will return a list of childrens based on the parent node.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;img height="473" alt="" width="607" src="/images/geekswithblogs_net/CalinTatar/Code(1).jpg" /&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/CalinTatar/aggbug/132157.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>CalinTatar</dc:creator>
            <guid>http://geekswithblogs.net/CalinTatar/archive/2009/05/16/retrieving-the-object-hierarchy-from-an-xml-with-linq-to.aspx</guid>
            <pubDate>Sat, 16 May 2009 06:03:50 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/CalinTatar/comments/132157.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/CalinTatar/archive/2009/05/16/retrieving-the-object-hierarchy-from-an-xml-with-linq-to.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/CalinTatar/comments/commentRss/132157.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>
