<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" version="2.0">
  <channel>
    <title>Steve Eichert - linq in action</title>
    <link>http://iqueryable.com/</link>
    <description />
    <language>en-us</language>
    <copyright>Steve Eichert</copyright>
    <lastBuildDate>Mon, 21 Jan 2008 14:32:52 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.9.6264.0</generator>
    <managingEditor>steve.eichert@gmail.com</managingEditor>
    <webMaster>steve.eichert@gmail.com</webMaster>
    <item>
      <trackback:ping>http://iqueryable.com/Trackback.aspx?guid=e37b5b23-a04e-4727-b938-6637a9e5c048</trackback:ping>
      <pingback:server>http://iqueryable.com/pingback.aspx</pingback:server>
      <pingback:target>http://iqueryable.com/PermaLink,guid,e37b5b23-a04e-4727-b938-6637a9e5c048.aspx</pingback:target>
      <dc:creator>Steve Eichert</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <iframe src="http://rcm.amazon.com/e/cm?t=steveeichert-20&amp;o=1&amp;p=8&amp;l=as1&amp;asins=1933988169&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr" style="padding: 5px; width: 120px; height: 240px;" marginwidth="3" marginheight="3" align="right" frameborder="0" scrolling="no">
        </iframe>
After many, many, many long months of work, LINQ in Action is finally done!  <a href="http://weblogs.asp.net/fmarguerie/">Fabrice</a>, <a href="http://www.devauthority.com/blogs/jwooley/">Jim</a>,
and I are very proud of the final product and really hope you enjoy it.  We've
already heard a lot of positive feedback from those who purchased the Early Access
Preview from Manning, and are hopefull that LINQ in Action will be a valuable resource
for everyone who is trying to add LINQ to their development toolbox.  My favorite
quote thus far is from Ben Hayat on the <a href="http://www.manning-sandbox.com/forum.jspa?forumID=302&amp;start=0">LINQ
in Action forums</a> where he said <a href="http://www.manning-sandbox.com/thread.jspa?threadID=22751&amp;tstart=0">"I
had gotten other books on Linq, and this book is simply the <b>BEST</b>!"</a>. 
Now for those of you who don't know Ben, it should be very clear that he's extremely
smart and intelligent and you should believe everything he says, especially when it
comes to what the best LINQ book is! :D  
<br /><br />
Since the book is on the printers as we speak, it isn't yet available on Amazon for
immediate shipping, however, I've been told it should make it's way over there in
the next couple of weeks.  Given that, now is a great time to head over and <a href="http://www.amazon.com/gp/product/1933988169?ie=UTF8&amp;tag=steveeichert-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1933988169">pre-order
it</a>!  If you want the book sooner rather than later the best way to get it
is <a href="http://www.manning.com/affiliate/idevaffiliate.php?id=253_74">directly
via Manning's website</a>.<br /><br />
To keep updated on the status of the book, including errata, code samples, or to ask
Fabrice, Jim, or I any questions about our <a href="http://www.linq-book.com/">LINQ
book</a> you should drop by the <a href="http://www.linq-book.com/">LINQ in Action
website</a> or the <a href="http://www.manning-sandbox.com/forum.jspa?forumID=302&amp;start=0">author
forums on the Manning website</a>.<br /><p></p><img width="0" height="0" src="http://iqueryable.com/aggbug.ashx?id=e37b5b23-a04e-4727-b938-6637a9e5c048" /></body>
      <title>Coming to a store near you...LINQ in Action!</title>
      <guid isPermaLink="false">http://iqueryable.com/PermaLink,guid,e37b5b23-a04e-4727-b938-6637a9e5c048.aspx</guid>
      <link>http://iqueryable.com/2008/01/21/ComingToAStoreNearYouLINQInAction.aspx</link>
      <pubDate>Mon, 21 Jan 2008 14:32:52 GMT</pubDate>
      <description>&lt;iframe src="http://rcm.amazon.com/e/cm?t=steveeichert-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=as1&amp;amp;asins=1933988169&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr" style="padding: 5px; width: 120px; height: 240px;" marginwidth="3" marginheight="3" align="right" frameborder="0" scrolling="no"&gt;
&lt;/iframe&gt;
After many, many, many long months of work, LINQ in Action is finally done!&amp;nbsp; &lt;a href="http://weblogs.asp.net/fmarguerie/"&gt;Fabrice&lt;/a&gt;, &lt;a href="http://www.devauthority.com/blogs/jwooley/"&gt;Jim&lt;/a&gt;,
and I are very proud of the final product and really hope you enjoy it.&amp;nbsp; We've
already heard a lot of positive feedback from those who purchased the Early Access
Preview from Manning, and are hopefull that LINQ in Action will be a valuable resource
for everyone who is trying to add LINQ to their development toolbox.&amp;nbsp; My favorite
quote thus far is from Ben Hayat on the &lt;a href="http://www.manning-sandbox.com/forum.jspa?forumID=302&amp;amp;start=0"&gt;LINQ
in Action forums&lt;/a&gt; where he said &lt;a href="http://www.manning-sandbox.com/thread.jspa?threadID=22751&amp;amp;tstart=0"&gt;"I
had gotten other books on Linq, and this book is simply the &lt;b&gt;BEST&lt;/b&gt;!"&lt;/a&gt;.&amp;nbsp;
Now for those of you who don't know Ben, it should be very clear that he's extremely
smart and intelligent and you should believe everything he says, especially when it
comes to what the best LINQ book is! :D&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
Since the book is on the printers as we speak, it isn't yet available on Amazon for
immediate shipping, however, I've been told it should make it's way over there in
the next couple of weeks.&amp;nbsp; Given that, now is a great time to head over and &lt;a href="http://www.amazon.com/gp/product/1933988169?ie=UTF8&amp;amp;tag=steveeichert-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=1933988169"&gt;pre-order
it&lt;/a&gt;!&amp;nbsp; If you want the book sooner rather than later the best way to get it
is &lt;a href="http://www.manning.com/affiliate/idevaffiliate.php?id=253_74"&gt;directly
via Manning's website&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
To keep updated on the status of the book, including errata, code samples, or to ask
Fabrice, Jim, or I any questions about our &lt;a href="http://www.linq-book.com/"&gt;LINQ
book&lt;/a&gt; you should drop by the &lt;a href="http://www.linq-book.com/"&gt;LINQ in Action
website&lt;/a&gt; or the &lt;a href="http://www.manning-sandbox.com/forum.jspa?forumID=302&amp;amp;start=0"&gt;author
forums on the Manning website&lt;/a&gt;.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://iqueryable.com/aggbug.ashx?id=e37b5b23-a04e-4727-b938-6637a9e5c048" /&gt;</description>
      <category>.net;books;linq;linq in action;linq to sql;linq to xml;writing</category>
    </item>
    <item>
      <trackback:ping>http://iqueryable.com/Trackback.aspx?guid=a8526041-6150-42d0-9c2f-70b195c0a43f</trackback:ping>
      <pingback:server>http://iqueryable.com/pingback.aspx</pingback:server>
      <pingback:target>http://iqueryable.com/PermaLink,guid,a8526041-6150-42d0-9c2f-70b195c0a43f.aspx</pingback:target>
      <dc:creator>Steve Eichert</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">Scott Hanselman and Carl Franklin <a href="http://www.hanselminutes.com/default.aspx?showID=97">talk
about LINQ to XML in the latest episode of Hanselminutes</a>.  Scott's done a
ton of work with existing .NET XML Api's, and has starting digging into what's available
with LINQ to XML.<br /><p></p><img width="0" height="0" src="http://iqueryable.com/aggbug.ashx?id=a8526041-6150-42d0-9c2f-70b195c0a43f" /></body>
      <title>Scott Hanselman and Carl Franklin talk LINQ to XML</title>
      <guid isPermaLink="false">http://iqueryable.com/PermaLink,guid,a8526041-6150-42d0-9c2f-70b195c0a43f.aspx</guid>
      <link>http://iqueryable.com/2007/08/31/ScottHanselmanAndCarlFranklinTalkLINQToXML.aspx</link>
      <pubDate>Fri, 31 Aug 2007 12:10:19 GMT</pubDate>
      <description>Scott Hanselman and Carl Franklin &lt;a href="http://www.hanselminutes.com/default.aspx?showID=97"&gt;talk
about LINQ to XML in the latest episode of Hanselminutes&lt;/a&gt;.&amp;nbsp; Scott's done a
ton of work with existing .NET XML Api's, and has starting digging into what's available
with LINQ to XML.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://iqueryable.com/aggbug.ashx?id=a8526041-6150-42d0-9c2f-70b195c0a43f" /&gt;</description>
      <category>linq in action;linq to xml</category>
    </item>
    <item>
      <trackback:ping>http://iqueryable.com/Trackback.aspx?guid=d2d87cba-d1c6-4d32-9869-32912b735eeb</trackback:ping>
      <pingback:server>http://iqueryable.com/pingback.aspx</pingback:server>
      <pingback:target>http://iqueryable.com/PermaLink,guid,d2d87cba-d1c6-4d32-9869-32912b735eeb.aspx</pingback:target>
      <dc:creator>Steve Eichert</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">A while back I posted an example of how
to <a href="http://steve.emxsoftware.com/LINQ/ConvertingaCSVfiletoXMLusingLINQtoXMLandFunctionalConstruction">convert
a comma seperated file (CSV) to XML using LINQ to XML and functional construction</a>. 
We're in the final push to get LINQ in Action to production and as such I've been
spending a lot of time going back through the chapters cleaning things up, as well
as making sure both a C# and VB.NET example is provided for every code sample presented
in the book.  Tonight I was converting a code sample from Chapter 12 that shows
how to convert a CSV file to XML using LINQ to XML.  While the <a href="http://steve.emxsoftware.com/LINQ/ConvertingaCSVfiletoXMLusingLINQtoXMLandFunctionalConstruction">C#
code is very nice</a>, I like the VB version that is shown below even better.<br /><br />
Imports System.IO<br />
Imports System.Xml.Linq<br /><br />
Module FlatFileToXmlWithXmlLiterals<br />
  Sub Main()<br />
    Dim xml As XElement = &lt;books&gt;<br />
                         
&lt;%= From line In File.ReadAllLines("books.txt") _<br />
                         
Where Not line.StartsWith("#") _<br />
                         
Let items = line.Split(",") _<br />
                         
Select _<br />
                         
&lt;book&gt;<br />
                           
&lt;title&gt;&lt;%= items(1) %&gt;&lt;/title&gt;<br />
                           
&lt;authors&gt;<br />
                             
&lt;%= From authorFullName In items(2).Split(";") _<br />
                               
Let authorNameParts = authorFullName.Split(" ") _<br />
                               
Select &lt;author&gt;<br />
                                        
&lt;firstName&gt;&lt;%= authorNameParts(0) %&gt;&lt;/firstName&gt;<br />
                                        
&lt;lastName&gt;&lt;%= authorNameParts(1) %&gt;&lt;/lastName&gt;<br />
                                      
&lt;/author&gt; _<br />
                             
%&gt;<br />
                           
&lt;/authors&gt;<br />
                           
&lt;publisher&gt;&lt;%= items(3) %&gt;&lt;/publisher&gt;<br />
                           
&lt;publicationDate&gt;&lt;%= items(4) %&gt;&lt;/publicationDate&gt;<br />
                           
&lt;price&gt;&lt;%= items(5) %&gt;&lt;/price&gt;<br />
                           
&lt;isbn&gt;&lt;%= items(0) %&gt;&lt;/isbn&gt;<br />
                         
&lt;/book&gt; _<br />
                       
%&gt;<br />
                     
&lt;/books&gt;<br /><br />
    Console.WriteLine(xml)<br />
  End Sub<br />
End Module<br /><br />
As an aside, if you've been meaning to <a href="http://www.manning.com/affiliate/idevaffiliate.php?id=253_74">learn
about LINQ</a>, or if you've already begun your journey, now is a great time to checkout
the <a href="http://www.manning.com/affiliate/idevaffiliate.php?id=253_74">early access
edition of LINQ in Action</a>.  We have every chapter available for download,
and will very shortly be making the source code available.  We still have a little
ways to go, but we're getting close!<br /><br />
Download the sample project here: <a href="http://iqueryable.com/content/binary/Chapter12.FlatFileToXml.Vb.zip">Chapter12.FlatFileToXml.Vb.zip
(10.09 KB)</a><img width="0" height="0" src="http://iqueryable.com/aggbug.ashx?id=d2d87cba-d1c6-4d32-9869-32912b735eeb" /></body>
      <title>Converting a CSV file to XML using VB 9 XML Literals</title>
      <guid isPermaLink="false">http://iqueryable.com/PermaLink,guid,d2d87cba-d1c6-4d32-9869-32912b735eeb.aspx</guid>
      <link>http://iqueryable.com/2007/08/31/ConvertingACSVFileToXMLUsingVB9XMLLiterals.aspx</link>
      <pubDate>Fri, 31 Aug 2007 01:26:49 GMT</pubDate>
      <description>A while back I posted an example of how to &lt;a href="http://steve.emxsoftware.com/LINQ/ConvertingaCSVfiletoXMLusingLINQtoXMLandFunctionalConstruction"&gt;convert
a comma seperated file (CSV) to XML using LINQ to XML and functional construction&lt;/a&gt;.&amp;nbsp;
We're in the final push to get LINQ in Action to production and as such I've been
spending a lot of time going back through the chapters cleaning things up, as well
as making sure both a C# and VB.NET example is provided for every code sample presented
in the book.&amp;nbsp; Tonight I was converting a code sample from Chapter 12 that shows
how to convert a CSV file to XML using LINQ to XML.&amp;nbsp; While the &lt;a href="http://steve.emxsoftware.com/LINQ/ConvertingaCSVfiletoXMLusingLINQtoXMLandFunctionalConstruction"&gt;C#
code is very nice&lt;/a&gt;, I like the VB version that is shown below even better.&lt;br&gt;
&lt;br&gt;
Imports System.IO&lt;br&gt;
Imports System.Xml.Linq&lt;br&gt;
&lt;br&gt;
Module FlatFileToXmlWithXmlLiterals&lt;br&gt;
&amp;nbsp; Sub Main()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim xml As XElement = &amp;lt;books&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;%= From line In File.ReadAllLines("books.txt") _&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Where Not line.StartsWith("#") _&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Let items = line.Split(",") _&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Select _&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;book&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;title&amp;gt;&amp;lt;%= items(1) %&amp;gt;&amp;lt;/title&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;authors&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;%= From authorFullName In items(2).Split(";") _&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Let authorNameParts = authorFullName.Split(" ") _&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Select &amp;lt;author&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;firstName&amp;gt;&amp;lt;%= authorNameParts(0) %&amp;gt;&amp;lt;/firstName&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;lastName&amp;gt;&amp;lt;%= authorNameParts(1) %&amp;gt;&amp;lt;/lastName&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/author&amp;gt; _&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
%&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/authors&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;publisher&amp;gt;&amp;lt;%= items(3) %&amp;gt;&amp;lt;/publisher&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;publicationDate&amp;gt;&amp;lt;%= items(4) %&amp;gt;&amp;lt;/publicationDate&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;price&amp;gt;&amp;lt;%= items(5) %&amp;gt;&amp;lt;/price&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;isbn&amp;gt;&amp;lt;%= items(0) %&amp;gt;&amp;lt;/isbn&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/book&amp;gt; _&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
%&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/books&amp;gt;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(xml)&lt;br&gt;
&amp;nbsp; End Sub&lt;br&gt;
End Module&lt;br&gt;
&lt;br&gt;
As an aside, if you've been meaning to &lt;a href="http://www.manning.com/affiliate/idevaffiliate.php?id=253_74"&gt;learn
about LINQ&lt;/a&gt;, or if you've already begun your journey, now is a great time to checkout
the &lt;a href="http://www.manning.com/affiliate/idevaffiliate.php?id=253_74"&gt;early access
edition of LINQ in Action&lt;/a&gt;.&amp;nbsp; We have every chapter available for download,
and will very shortly be making the source code available.&amp;nbsp; We still have a little
ways to go, but we're getting close!&lt;br&gt;
&lt;br&gt;
Download the sample project here: &lt;a href="http://iqueryable.com/content/binary/Chapter12.FlatFileToXml.Vb.zip"&gt;Chapter12.FlatFileToXml.Vb.zip
(10.09 KB)&lt;/a&gt;&lt;img width="0" height="0" src="http://iqueryable.com/aggbug.ashx?id=d2d87cba-d1c6-4d32-9869-32912b735eeb" /&gt;</description>
      <category>books;linq;linq in action;linq to xml</category>
    </item>
    <item>
      <trackback:ping>http://iqueryable.com/Trackback.aspx?guid=0508b835-90cf-45fc-95ff-1721342f2bda</trackback:ping>
      <pingback:server>http://iqueryable.com/pingback.aspx</pingback:server>
      <pingback:target>http://iqueryable.com/PermaLink,guid,0508b835-90cf-45fc-95ff-1721342f2bda.aspx</pingback:target>
      <dc:creator>Steve Eichert</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">While working on our <a href="http://www.manning.com/affiliate/idevaffiliate.php?id=253_74">LINQ
book</a> I've come to really enjoy LINQ to XML. I've worked with a lot of XML API's
over the years, however, the LINQ to XML API is my favorite...by far. In addition
to providing all the nice query facilities made available by LINQ, it also provides
a lot of other great features that many people overlook. As I promised long ago, I'm
going to begin to talk about the things that I enjoy about LINQ to XML in hopes that
it will help you realize that the red headed step child of LINQ has some things to
offer the world as well. :) 
<br /><br />
One of the most common things that we need to do when dealing with XML is transform
it. We're usually transforming it into an alternate XML format, or transforming the
XML into a set of objects. In this post I'm going to quickly look at some of the transformation
capabilities offered by LINQ to XML. To help us get started I'm going to use the following
XML which is the XML representation of a contact in <a href="http://highrisehq.com">Highrise</a>. 
<br /><br />
&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;person&gt;<br />
  &lt;author-id type="integer"&gt;1436&lt;/author-id&gt;<br />
  &lt;background/&gt;<br />
  &lt;company-id type="integer"&gt;1226900&lt;/company-id&gt;<br />
  &lt;created-at type="datetime"&gt;2007-06-09T03:13:15Z&lt;/created-at&gt;<br />
  &lt;first-name&gt;Steve&lt;/first-name&gt;<br />
  &lt;group-id type="integer"/&gt;<br />
  &lt;id type="integer"&gt;1226899&lt;/id&gt;<br />
  &lt;last-name&gt;Eichert&lt;/last-name&gt;<br />
  &lt;owner-id type="integer"/&gt;<br />
  &lt;title/&gt;<br />
  &lt;updated-at type="datetime"&gt;2007-06-09T03:15:16Z&lt;/updated-at&gt;<br />
  &lt;visible-to&gt;Everyone&lt;/visible-to&gt;<br />
  &lt;contact-data&gt;<br />
    &lt;email-addresses type="array"&gt;<br />
      &lt;email-address&gt;<br />
        &lt;address&gt;steve.eichert at google
mail dot com&lt;/address&gt;<br />
        &lt;id type="integer"&gt;559722&lt;/id&gt;<br />
        &lt;location&gt;Work&lt;/location&gt;<br />
      &lt;/email-address&gt;<br />
    &lt;/email-addresses&gt;<br />
    &lt;web-addresses type="array"&gt;<br />
      &lt;web-address&gt;<br />
        &lt;id type="integer"&gt;942962&lt;/id&gt;<br />
        &lt;location&gt;Work&lt;/location&gt;<br />
        &lt;url&gt;http://iqueryable.com/&lt;/url&gt;<br />
      &lt;/web-address&gt;<br />
    &lt;/web-addresses&gt;<br />
  &lt;/contact-data&gt;<br />
&lt;/person&gt;<br /><br />
Rather than be stuck with our contact in XML, let's see what we can do to transform
the above XML into the <a href="http://en.wikipedia.org/wiki/HCard">hCard microformat</a>.
We're going to ignore a bunch of data, such as all the ids, since it doesn't have
any meaning outside of Highrise. When we're done we'll end up with the much simplified
XML shown below: 
<br /><br />
&lt;div class="vcard"&gt;<br />
  &lt;div class="fn"&gt;Steve Eichert&lt;/div&gt;<br />
  &lt;div&gt;Email: &lt;span class="email"&gt;steve.eichert at google mail dot
com&lt;/span&gt;&lt;/div&gt;<br />
  &lt;a class="url" href="http://iqueryable.com/"&gt;http://iqueryable.com/&lt;/a&gt;<br />
&lt;/div&gt;<br /><br />
The first step for transforming our Highrise XML into the hCard microformat is to
load the Highrise XML into an XElement. 
<p></p><p>
XElement highriseRoot = XElement.Load("highrise-contact.xml");<br /></p><p>
We use the static Load method of XElement to load the XML contained within the "highrise-contact.xml"
file that we've saved locally. I don't believe the Highrise API is officially supported
at the moment so I'm not going to load the contact details directly from the highrisehq.com
site. Perhaps, in a future post we can explore that as an option. 
</p><p></p><p>
Anywho, once our XML is loaded into an XElement, we can transform our Highrise XML
into the hCard microformat by building a new XElement. We'll use the Element query
axis method to retrieve the first and last name of the contact, and we'll embed query
expressions and make use of the Descendants query axis method for selecting all the
email and web addresses for the contact within the source XML. When we put it all
together we end up with the C# code below:
</p><p>
XElement highriseRoot = XElement.Load("highrise-contact.xml");<br /><br />
XElement hCard = 
<br />
    new XElement("div",<br />
        new XAttribute("class", "vcard"),<br />
        new XElement("div",<br />
            new XAttribute("class", "fn"),<br />
            highriseRoot.Element("first-name")
+ " " + highriseRoot.Element("last-name")<br />
        ),<br />
        from emailElement in highriseRoot.Descendants("email-address")<br />
        select new XElement("div",<br />
            "Email:",<br />
            new XElement("span",<br />
                new XAttribute("class",
"email"),<br />
                (string)
emailElement.Element("address")<br />
            )<br />
        ),<br />
        from webElement in highriseRoot.Descendants("web-address")<br />
        select 
<br />
        new XElement("a",<br />
            new XAttribute("class", "url"),<br />
            new XAttribute("href", (string)
webElement.Element("url")),<br />
            (string) webElement.Element("url")<br />
        )<br />
    );<br /><br />
Console.WriteLine(hCard);<br /></p><p></p><p>
At first glance, the above code might be overwhelming. However, once you come to understand
the power of functional construction you'll quickly realize how wonderful LINQ to
XML can be for transforming XML to alternate XML formats. In addition to making it
easy to transform XML into alternate XML formats, LINQ to XML also makes it very easy
to transform XML into objects. If we have a Contact class defined as: 
</p><p></p><p>
public class Contact {<br />
    public string Name { get; set; }<br />
    public IEnumerable&lt;string&gt; EmailAddresses { get; set; }<br />
    public IEnumerable&lt;string&gt; Urls { get; set; }<br />
}
</p><p>
We can transform the contact details in our XML into a Contact instance with the following
code:
</p><p>
Contact contact = new Contact {<br />
    Name = (string) highriseRoot.Element("first-name") + " " + (string)
highriseRoot.Element("last-name"),<br />
    EmailAddresses = highriseRoot.Descendants("email-address").Select(e
=&gt; (string)e.Element("address")),<br />
    Urls = highriseRoot.Descendants("web-address").Select(e =&gt; (string)e.Element("url"))<br />
};<br /></p><p></p><p>
After looking back at the sample here I wish I had chosen an XML fragment with a little
more hierarchy, however it's much too late for that now. Hopefully, the code included
in this post gives you a small taste of the types of XML transformations possible
with LINQ to XML. As you begin to work with LINQ to XML, you'll find that functional
construction, combined with query axis methods, and query expressions provide a tremendous
amount of flexibility for transforming XML. Additionally, the new object initializer
syntax and LINQ to XML's ability to easily construct objects from XML makes it very
easy to create objects from XML. I've attached a zip file with the code above to this
post. (VS2008 Beta 2 Required) <a href="http://iqueryable.com/content/binary/LINQtoXMLTransformSample.zip">LINQtoXMLTransformSample.zip
(23.69 KB)</a></p><img width="0" height="0" src="http://iqueryable.com/aggbug.ashx?id=0508b835-90cf-45fc-95ff-1721342f2bda" /></body>
      <title>Transforming XML with LINQ to XML</title>
      <guid isPermaLink="false">http://iqueryable.com/PermaLink,guid,0508b835-90cf-45fc-95ff-1721342f2bda.aspx</guid>
      <link>http://iqueryable.com/2007/08/03/TransformingXMLWithLINQToXML.aspx</link>
      <pubDate>Fri, 03 Aug 2007 03:20:02 GMT</pubDate>
      <description>While working on our &lt;a href="http://www.manning.com/affiliate/idevaffiliate.php?id=253_74"&gt;LINQ
book&lt;/a&gt; I've come to really enjoy LINQ to XML. I've worked with a lot of XML API's
over the years, however, the LINQ to XML API is my favorite...by far. In addition
to providing all the nice query facilities made available by LINQ, it also provides
a lot of other great features that many people overlook. As I promised long ago, I'm
going to begin to talk about the things that I enjoy about LINQ to XML in hopes that
it will help you realize that the red headed step child of LINQ has some things to
offer the world as well. :) 
&lt;br&gt;
&lt;br&gt;
One of the most common things that we need to do when dealing with XML is transform
it. We're usually transforming it into an alternate XML format, or transforming the
XML into a set of objects. In this post I'm going to quickly look at some of the transformation
capabilities offered by LINQ to XML. To help us get started I'm going to use the following
XML which is the XML representation of a contact in &lt;a href="http://highrisehq.com"&gt;Highrise&lt;/a&gt;. 
&lt;br&gt;
&lt;br&gt;
&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br&gt;
&amp;lt;person&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;author-id type="integer"&amp;gt;1436&amp;lt;/author-id&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;background/&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;company-id type="integer"&amp;gt;1226900&amp;lt;/company-id&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;created-at type="datetime"&amp;gt;2007-06-09T03:13:15Z&amp;lt;/created-at&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;first-name&amp;gt;Steve&amp;lt;/first-name&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;group-id type="integer"/&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;id type="integer"&amp;gt;1226899&amp;lt;/id&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;last-name&amp;gt;Eichert&amp;lt;/last-name&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;owner-id type="integer"/&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;title/&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;updated-at type="datetime"&amp;gt;2007-06-09T03:15:16Z&amp;lt;/updated-at&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;visible-to&amp;gt;Everyone&amp;lt;/visible-to&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;contact-data&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;email-addresses type="array"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;email-address&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;address&amp;gt;steve.eichert at google
mail dot com&amp;lt;/address&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;id type="integer"&amp;gt;559722&amp;lt;/id&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;location&amp;gt;Work&amp;lt;/location&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/email-address&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/email-addresses&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;web-addresses type="array"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;web-address&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;id type="integer"&amp;gt;942962&amp;lt;/id&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;location&amp;gt;Work&amp;lt;/location&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;url&amp;gt;http://iqueryable.com/&amp;lt;/url&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/web-address&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/web-addresses&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/contact-data&amp;gt;&lt;br&gt;
&amp;lt;/person&amp;gt;&lt;br&gt;
&lt;br&gt;
Rather than be stuck with our contact in XML, let's see what we can do to transform
the above XML into the &lt;a href="http://en.wikipedia.org/wiki/HCard"&gt;hCard microformat&lt;/a&gt;.
We're going to ignore a bunch of data, such as all the ids, since it doesn't have
any meaning outside of Highrise. When we're done we'll end up with the much simplified
XML shown below: 
&lt;br&gt;
&lt;br&gt;
&amp;lt;div class="vcard"&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;div class="fn"&amp;gt;Steve Eichert&amp;lt;/div&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;div&amp;gt;Email: &amp;lt;span class="email"&amp;gt;steve.eichert at google mail dot
com&amp;lt;/span&amp;gt;&amp;lt;/div&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;a class="url" href="http://iqueryable.com/"&amp;gt;http://iqueryable.com/&amp;lt;/a&amp;gt;&lt;br&gt;
&amp;lt;/div&amp;gt;&lt;br&gt;
&lt;br&gt;
The first step for transforming our Highrise XML into the hCard microformat is to
load the Highrise XML into an XElement. 
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
XElement highriseRoot = XElement.Load("highrise-contact.xml");&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
We use the static Load method of XElement to load the XML contained within the "highrise-contact.xml"
file that we've saved locally. I don't believe the Highrise API is officially supported
at the moment so I'm not going to load the contact details directly from the highrisehq.com
site. Perhaps, in a future post we can explore that as an option. 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Anywho, once our XML is loaded into an XElement, we can transform our Highrise XML
into the hCard microformat by building a new XElement. We'll use the Element query
axis method to retrieve the first and last name of the contact, and we'll embed query
expressions and make use of the Descendants query axis method for selecting all the
email and web addresses for the contact within the source XML. When we put it all
together we end up with the C# code below:
&lt;/p&gt;
&lt;p&gt;
XElement highriseRoot = XElement.Load("highrise-contact.xml");&lt;br&gt;
&lt;br&gt;
XElement hCard = 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; new XElement("div",&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; new XAttribute("class", "vcard"),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; new XElement("div",&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; new XAttribute("class", "fn"),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; highriseRoot.Element("first-name")
+ " " + highriseRoot.Element("last-name")&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; from emailElement in highriseRoot.Descendants("email-address")&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; select new XElement("div",&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; "Email:",&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; new XElement("span",&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; new XAttribute("class",
"email"),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (string)
emailElement.Element("address")&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; from webElement in highriseRoot.Descendants("web-address")&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; select 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; new XElement("a",&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; new XAttribute("class", "url"),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; new XAttribute("href", (string)
webElement.Element("url")),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (string) webElement.Element("url")&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;br&gt;
&lt;br&gt;
Console.WriteLine(hCard);&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
At first glance, the above code might be overwhelming. However, once you come to understand
the power of functional construction you'll quickly realize how wonderful LINQ to
XML can be for transforming XML to alternate XML formats. In addition to making it
easy to transform XML into alternate XML formats, LINQ to XML also makes it very easy
to transform XML into objects. If we have a Contact class defined as: 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
public class Contact {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; set; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public IEnumerable&amp;lt;string&amp;gt; EmailAddresses { get; set; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public IEnumerable&amp;lt;string&amp;gt; Urls { get; set; }&lt;br&gt;
}
&lt;/p&gt;
&lt;p&gt;
We can transform the contact details in our XML into a Contact instance with the following
code:
&lt;/p&gt;
&lt;p&gt;
Contact contact = new Contact {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Name = (string) highriseRoot.Element("first-name") + " " + (string)
highriseRoot.Element("last-name"),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; EmailAddresses = highriseRoot.Descendants("email-address").Select(e
=&amp;gt; (string)e.Element("address")),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Urls = highriseRoot.Descendants("web-address").Select(e =&amp;gt; (string)e.Element("url"))&lt;br&gt;
};&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
After looking back at the sample here I wish I had chosen an XML fragment with a little
more hierarchy, however it's much too late for that now. Hopefully, the code included
in this post gives you a small taste of the types of XML transformations possible
with LINQ to XML. As you begin to work with LINQ to XML, you'll find that functional
construction, combined with query axis methods, and query expressions provide a tremendous
amount of flexibility for transforming XML. Additionally, the new object initializer
syntax and LINQ to XML's ability to easily construct objects from XML makes it very
easy to create objects from XML. I've attached a zip file with the code above to this
post. (VS2008 Beta 2 Required) &lt;a href="http://iqueryable.com/content/binary/LINQtoXMLTransformSample.zip"&gt;LINQtoXMLTransformSample.zip
(23.69 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://iqueryable.com/aggbug.ashx?id=0508b835-90cf-45fc-95ff-1721342f2bda" /&gt;</description>
      <category>linq;linq in action;linq to xml</category>
    </item>
    <item>
      <trackback:ping>http://iqueryable.com/Trackback.aspx?guid=304def0e-1c56-42f0-91fc-b525def18c23</trackback:ping>
      <pingback:server>http://iqueryable.com/pingback.aspx</pingback:server>
      <pingback:target>http://iqueryable.com/PermaLink,guid,304def0e-1c56-42f0-91fc-b525def18c23.aspx</pingback:target>
      <dc:creator>Steve Eichert</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">I had a jolly good fun time tonight updating
my code samples to the March CTP of Orcas.  Well, actually, I'm not quite finished
as of yet because of the wonderful error in the title of this post.  It appears
VS.NET Orcas doesn't want to let me recreate my data connection for my database that
I'm using for some LINQ to SQL examples. Woot!  Hopefully I'll figure out what
the dealy is shortly because I've got chapters I need to finish. :)<br /><p></p><img width="0" height="0" src="http://iqueryable.com/aggbug.ashx?id=304def0e-1c56-42f0-91fc-b525def18c23" /></body>
      <title>Orcas March CTP - Unable to find the requested .NET Framework Data provider</title>
      <guid isPermaLink="false">http://iqueryable.com/PermaLink,guid,304def0e-1c56-42f0-91fc-b525def18c23.aspx</guid>
      <link>http://iqueryable.com/2007/03/06/OrcasMarchCTPUnableToFindTheRequestedNETFrameworkDataProvider.aspx</link>
      <pubDate>Tue, 06 Mar 2007 03:20:47 GMT</pubDate>
      <description>I had a jolly good fun time tonight updating my code samples to the March CTP of Orcas.&amp;nbsp; Well, actually, I'm not quite finished as of yet because of the wonderful error in the title of this post.&amp;nbsp; It appears VS.NET Orcas doesn't want to let me recreate my data connection for my database that I'm using for some LINQ to SQL examples. Woot!&amp;nbsp; Hopefully I'll figure out what the dealy is shortly because I've got chapters I need to finish. :)&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://iqueryable.com/aggbug.ashx?id=304def0e-1c56-42f0-91fc-b525def18c23" /&gt;</description>
      <category>.net;linq;linq in action;orcas</category>
    </item>
    <item>
      <trackback:ping>http://iqueryable.com/Trackback.aspx?guid=89e14b37-1b4e-4831-82d0-16673558be54</trackback:ping>
      <pingback:server>http://iqueryable.com/pingback.aspx</pingback:server>
      <pingback:target>http://iqueryable.com/PermaLink,guid,89e14b37-1b4e-4831-82d0-16673558be54.aspx</pingback:target>
      <dc:creator>Steve Eichert</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">Over the last several months I've grown
to have an amazing amount of respect for people who write technical books.  It's
an amazingly time consuming process that involves a lot of staring at the screen wondering
what the heck to write next.  There are an infinite number of ways to phrase
every sentence, and your choice has a huge impact on whether or not the reader will
get what you're trying to say.  On top of that, for me, writing is nowhere near
as interesting as actually using the technology you're writing about.  I can't
tell you how many times I've wished I could get the heck out of Word and into Visual
Studio.  Layer on top a busy work and family life and you have something that
I've found amazingly difficult.  Since I have a full time gig I have to write
in the evenings and weekends.  With a wife and two young kids I'm not exactly
oozing with tons of free time.  Writing is amazingly difficult.  
<br /><br />
Rather than end this post and leave it as a paragraph of me complaining about how
hard I'm finding writing, let me leave you with some tips that I've found to help
in the writing process.<br /><ul><li>
Find someplace quite to work.  Unlike programming (and other tasks) where a little
bit of background noise and/or music can be beneficial, writing needs quite and needs
thought.  Find someplace you can think.  Don't try and get a little bit
of writing done while you try and do something else (such as watch after the kiddos).</li><li>
Start with an outline of what your going to write.  Include the key goals that
you have for each section and make sure you address each goal before you finish the
section, or chapter.</li><li>
With your first draft don't worry about how terrible things sounds, how rough around
the edges your points and/or description are, and how utterly crappy things flow. 
Get your thoughts on paper.  Once you get everything out, go back and revise
mercilessly until things sounds the way you want.</li><li>
Always think about the reader.  How will they expect to consume the information
you're presenting?  What will they arleady know? What might they need to be reminded
of?  How can you leverage what they know to help them learn what you're writing
about?</li><li>
Don't be boring.  This might sounds obvious but I've found it very hard to present
everything you want the reader to learn without having things turn into an unending
flow of technical details, which results in boredom.  It's important to remember
the reader needs breaks, encouragement, and direction.  And they also need to
not be bored.</li><li>
Instead of writing blog posts about how hard writing is and then spewing off a bunch
of writing tips (as if you have any clue what you're talking about) stay focused on
your book and the deadlines you have....doh! :)<br /></li></ul><img width="0" height="0" src="http://iqueryable.com/aggbug.ashx?id=89e14b37-1b4e-4831-82d0-16673558be54" /></body>
      <title>Writing a Book is Hard!</title>
      <guid isPermaLink="false">http://iqueryable.com/PermaLink,guid,89e14b37-1b4e-4831-82d0-16673558be54.aspx</guid>
      <link>http://iqueryable.com/2007/02/14/WritingABookIsHard.aspx</link>
      <pubDate>Wed, 14 Feb 2007 03:23:17 GMT</pubDate>
      <description>Over the last several months I've grown to have an amazing amount of respect for people who write technical books.&amp;nbsp; It's an amazingly time consuming process that involves a lot of staring at the screen wondering what the heck to write next.&amp;nbsp; There are an infinite number of ways to phrase every sentence, and your choice has a huge impact on whether or not the reader will get what you're trying to say.&amp;nbsp; On top of that, for me, writing is nowhere near as interesting as actually using the technology you're writing about.&amp;nbsp; I can't tell you how many times I've wished I could get the heck out of Word and into Visual Studio.&amp;nbsp; Layer on top a busy work and family life and you have something that I've found amazingly difficult.&amp;nbsp; Since I have a full time gig I have to write in the evenings and weekends.&amp;nbsp; With a wife and two young kids I'm not exactly oozing with tons of free time.&amp;nbsp; Writing is amazingly difficult.&amp;nbsp; &lt;br&gt;
&lt;br&gt;
Rather than end this post and leave it as a paragraph of me complaining about how
hard I'm finding writing, let me leave you with some tips that I've found to help
in the writing process.&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;
Find someplace quite to work.&amp;nbsp; Unlike programming (and other tasks) where a little
bit of background noise and/or music can be beneficial, writing needs quite and needs
thought.&amp;nbsp; Find someplace you can think.&amp;nbsp; Don't try and get a little bit
of writing done while you try and do something else (such as watch after the kiddos).&lt;/li&gt;
&lt;li&gt;
Start with an outline of what your going to write.&amp;nbsp; Include the key goals that
you have for each section and make sure you address each goal before you finish the
section, or chapter.&lt;/li&gt;
&lt;li&gt;
With your first draft don't worry about how terrible things sounds, how rough around
the edges your points and/or description are, and how utterly crappy things flow.&amp;nbsp;
Get your thoughts on paper.&amp;nbsp; Once you get everything out, go back and revise
mercilessly until things sounds the way you want.&lt;/li&gt;
&lt;li&gt;
Always think about the reader.&amp;nbsp; How will they expect to consume the information
you're presenting?&amp;nbsp; What will they arleady know? What might they need to be reminded
of?&amp;nbsp; How can you leverage what they know to help them learn what you're writing
about?&lt;/li&gt;
&lt;li&gt;
Don't be boring.&amp;nbsp; This might sounds obvious but I've found it very hard to present
everything you want the reader to learn without having things turn into an unending
flow of technical details, which results in boredom.&amp;nbsp; It's important to remember
the reader needs breaks, encouragement, and direction.&amp;nbsp; And they also need to
not be bored.&lt;/li&gt;
&lt;li&gt;
Instead of writing blog posts about how hard writing is and then spewing off a bunch
of writing tips (as if you have any clue what you're talking about) stay focused on
your book and the deadlines you have....doh! :)&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://iqueryable.com/aggbug.ashx?id=89e14b37-1b4e-4831-82d0-16673558be54" /&gt;</description>
      <category>linq in action;writing</category>
    </item>
  </channel>
</rss>