<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;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132157"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=132157" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&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 19: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>
            <wfw:commentRss>http://geekswithblogs.net/CalinTatar/comments/commentRss/132157.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>