<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>XML Literals: Creating an XML File</title><link>http://msmvps.com/blogs/deborahk/archive/2009/07/02/xml-literals-creating-an-xml-file.aspx</link><description>One of my favorite features in VB 9 (Visual Studio 2008) is XML Literals. This example demonstrates how insanely easy it is to build an XML file using VB. This code builds XML from a list of customers. Dim customerXml As XElement = _ &amp;lt;customers&amp;gt;</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>re: XML Literals: Creating an XML File</title><link>http://msmvps.com/blogs/deborahk/archive/2009/07/02/xml-literals-creating-an-xml-file.aspx#1731118</link><pubDate>Fri, 09 Oct 2009 22:59:42 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1731118</guid><dc:creator>Deborah Kurata</dc:creator><description>&lt;p&gt;Hi Jerry -&lt;/p&gt;
&lt;p&gt;Thank you for coming by the blog. XML Literals are a feature of VB.NET only.&lt;/p&gt;
&lt;p&gt;To add an attribute, the code would look something like this:&lt;/p&gt;
&lt;p&gt;Dim customerXml As XElement = _ &lt;/p&gt;
&lt;p&gt;&amp;lt;customers&amp;gt; &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;lt;%= From c In custList _ &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; Select &amp;lt;customer id=&amp;lt;%= c.CustomerId %&amp;gt;&amp;gt; &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;LastName&amp;gt;&amp;lt;%= c.LastName %&amp;gt;&amp;lt;/LastName&amp;gt; &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;FirstName&amp;gt;&amp;lt;%= c.FirstName %&amp;gt;&amp;lt;/FirstName&amp;gt; &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/customer&amp;gt; %&amp;gt; &lt;/p&gt;
&lt;p&gt;&amp;lt;/customers&amp;gt; &lt;/p&gt;
&lt;p&gt;Hope this helps.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1731118" width="1" height="1"&gt;</description></item><item><title>But what about attributes?</title><link>http://msmvps.com/blogs/deborahk/archive/2009/07/02/xml-literals-creating-an-xml-file.aspx#1731039</link><pubDate>Fri, 09 Oct 2009 13:23:23 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1731039</guid><dc:creator>Jerry T.</dc:creator><description>&lt;p&gt;This looks very simple. Is this an aspect of LINQ or just part of VB.NET itself now?&lt;/p&gt;
&lt;p&gt;ALSO, how would one add an attribute to the Customer element such that it read like this:&lt;/p&gt;
&lt;p&gt;&amp;lt;Customer id=&amp;quot;12345&amp;quot;&amp;gt; in the resulting XML&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1731039" width="1" height="1"&gt;</description></item><item><title>Formatting Text Files</title><link>http://msmvps.com/blogs/deborahk/archive/2009/07/02/xml-literals-creating-an-xml-file.aspx#1704716</link><pubDate>Tue, 21 Jul 2009 20:16:29 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1704716</guid><dc:creator>Deborah's Developer MindScape</dc:creator><description>&lt;p&gt;There are often times that you need to write out text files containing data managed by your application&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1704716" width="1" height="1"&gt;</description></item><item><title>re: XML Literals: Creating an XML File</title><link>http://msmvps.com/blogs/deborahk/archive/2009/07/02/xml-literals-creating-an-xml-file.aspx#1702609</link><pubDate>Fri, 17 Jul 2009 15:36:33 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1702609</guid><dc:creator>Deborah Kurata</dc:creator><description>&lt;p&gt;Hi Miller -&lt;/p&gt;
&lt;p&gt;No. As it states at the top of the post, this is for Visual Studio 2008, .NET Framework 3.5.&lt;/p&gt;
&lt;p&gt;(Guess I should have asked that before linking you to this page.)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1702609" width="1" height="1"&gt;</description></item><item><title>re: XML Literals: Creating an XML File</title><link>http://msmvps.com/blogs/deborahk/archive/2009/07/02/xml-literals-creating-an-xml-file.aspx#1702509</link><pubDate>Fri, 17 Jul 2009 06:59:09 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1702509</guid><dc:creator>Miller_a</dc:creator><description>&lt;p&gt;Hi Deborah, &lt;/p&gt;
&lt;p&gt;I was directed here by you to look at this, does this work on .net framework 2.0 with visual studo 2005?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1702509" width="1" height="1"&gt;</description></item><item><title>XML Literals: Reading an XML File</title><link>http://msmvps.com/blogs/deborahk/archive/2009/07/02/xml-literals-creating-an-xml-file.aspx#1698831</link><pubDate>Wed, 08 Jul 2009 21:28:24 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1698831</guid><dc:creator>Deborah's Developer MindScape</dc:creator><description>&lt;p&gt;In a prior post here , I created an XML file using VB 9 (Visual Basic 2008/.NET Framework 3.5). This&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1698831" width="1" height="1"&gt;</description></item></channel></rss>