Tuesday, December 18, 2007

If you've ever listened to Hanselminutes, you've no doubt heard Scott mention "code smell" or "pretty code".  The new language features in VB9, including LINQ and XML being a native type, make XML generation not only easy, but beautiful.  Aside from the color scheme, look at how smooth this code snippet is.

Dim _order As New XElement(<Order>
    <ShipperRef><%= h.UniqueRef %></ShipperRef>
    <UniqueRef><%= IIf(h.CustomerPo <> "", h.CustomerPo, h.JdeNumber) %></UniqueRef>
    <Comments><%= _orderComments %></Comments>
    <OrderType><%= h.OrderType %></OrderType>
    <Workflow><%= h.Workflow %></Workflow>
    <RORRelationship><%= h.RORRelationship %></RORRelationship>
    <Supplier><%= h.SupplierNumber.ToString %></Supplier>
    <Customer><%= h.Customer.ToString %></Customer>
    <FreightBillableParty><%= h.FreightBillableParty %></FreightBillableParty>
    <MethodOfPayment>Prepay</MethodOfPayment>
    <HAZMAT><%= h.Hazmat %></HAZMAT>
    <GroupAssignment><%= SetGroupAssignment(h.GroupAssignment) %></GroupAssignment>
    <Weight><%= _orderWeight.ToString %></Weight>
    <Volume><%= _orderCube.ToString %></Volume>
    <OrderContact><%= h.PrimaryContactAssignment %></OrderContact>
    <ShipmentContact><%= h.PrimaryContactAssignment %></ShipmentContact>
    </Order>)

My VS 2008 theme is DesertNights, and the code was copied with CopySourceAsHtml.

 |  |  | 
Tuesday, December 18, 2007 12:41:21 PM (Eastern Standard Time, UTC-05:00)
 Wednesday, August 30, 2006

Super simple and sweet:

So I was looking for a real quick way to publish an RSS feed from a Web application I created for a friend and found some great articles and components (RSS Toolkit for ASP.NET 2.0.)  However, I didn t find anything that used XML Serialization (specifically) to work with the RSS 2.0 Specification (maybe my Google skills are truly weak today.)  I use XmlSerializer religiously, and thought it would be quite trivial to build a set of classes to quickly create and publish an RSS feed.   Thus, as any geek would do, I did just that.

...

These classes are adorned with System.Xml.Serialization attributes, which comply with the RSS 2.0 Specification.   To create an RSS document, it s no more difficult than creating and populating a PONO (Plain Ole .NET Object.)

Full story at http://weblogs.asp.net/skillet/archive/2006/08/29/RSS-in-.NET-Made-Easy-with-XML-Serialization.aspx

Hat tip: Greg's Cool ...

kick it on DotNetKicks.com

Wednesday, August 30, 2006 5:55:00 PM (Eastern Standard Time, UTC-05:00)