<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.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>Convert CSV to XML</title><link>http://blogs.msdn.com/kaevans/archive/2003/04/17/5780.aspx</link><description>How to transform CSV to an XML format?</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Convert CSV to XML</title><link>http://blogs.msdn.com/kaevans/archive/2003/04/17/5780.aspx#13318</link><pubDate>Thu, 17 Apr 2003 18:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:13318</guid><dc:creator>Martin Spedding</dc:creator><description>Hiya, 
&lt;br&gt;
have look at 
&lt;br&gt;

&lt;br&gt;
http://www.develop.com/devresources/resourcedetail.aspx?type=t&amp;amp;id=864
&lt;br&gt;

&lt;br&gt;
It is an implementation of a custom xmlreader and xmlwriter. If I remember correctly there is an example for a csv file and for a zip file. This way the csv appears as though it is an XML file and it means that you can  perform xpath queries or xsl transformations on the csv file without having to transform it directly to an xml file.
&lt;br&gt;

&lt;br&gt;
Have a good Easter
&lt;br&gt;

&lt;br&gt;
Martin
&lt;br&gt;
</description></item><item><title>re: Convert CSV to XML</title><link>http://blogs.msdn.com/kaevans/archive/2003/04/17/5780.aspx#13592</link><pubDate>Thu, 24 Apr 2003 11:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:13592</guid><dc:creator>Bjørn Reppen</dc:creator><description>Why not just write it in IL to make sure nobody can read the code? :-D</description></item><item><title>re: Convert CSV to XML</title><link>http://blogs.msdn.com/kaevans/archive/2003/04/17/5780.aspx#13927</link><pubDate>Sat, 03 May 2003 15:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:13927</guid><dc:creator>Dimitre Novatchev</dc:creator><description>This is something trivial when using the FXSL functional programming library for XSLT. 
&lt;br&gt;

&lt;br&gt;
Just use the &amp;quot;str-split-to-words&amp;quot; template.
&lt;br&gt;

&lt;br&gt;
This template is quite general. For example it allows to specify *a set of* different potential delimiters, each of which may be used at some place and more than one of them may be used in the same string.
&lt;br&gt;

&lt;br&gt;
To illustrate the power of &amp;quot;str-split-to-words&amp;quot;, there's the solution of the problem to &amp;quot;re-allocate&amp;quot; a relative file path, when the template that contains the rel-path (e.g. in xsl:import) is moved into a different folder.
&lt;br&gt;

&lt;br&gt;
See it here:
&lt;br&gt;

&lt;br&gt;
http://groups.google.com/groups?dq=&amp;amp;hl=en&amp;amp;lr=&amp;amp;ie=UTF-8&amp;amp;oe=UTF-8&amp;amp;group=microsoft.public.xml&amp;amp;selm=b8ujil%24dpl9r%241%40ID-152440.news.dfncis.de
&lt;br&gt;

&lt;br&gt;

&lt;br&gt;
Cheers,
&lt;br&gt;

&lt;br&gt;
=====
&lt;br&gt;
Cheers,
&lt;br&gt;

&lt;br&gt;
Dimitre Novatchev.
&lt;br&gt;
http://fxsl.sourceforge.net/ -- the home of FXSL
&lt;br&gt;
</description></item><item><title>Cool info : Bob.NET</title><link>http://blogs.msdn.com/kaevans/archive/2003/04/17/5780.aspx#20662</link><pubDate>Thu, 17 Apr 2003 21:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:20662</guid><dc:creator>TrackBack</dc:creator><description>Cool info : Bob.NET</description></item><item><title>The output is actually different</title><link>http://blogs.msdn.com/kaevans/archive/2003/04/17/5780.aspx#156969</link><pubDate>Wed, 16 Jun 2004 13:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:156969</guid><dc:creator>Paul Owen</dc:creator><description>The output is not actually as you've written it there. It would actually be:&lt;br&gt;&lt;br&gt;&amp;lt;root&amp;gt;&lt;br&gt;&amp;lt;row&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt;1&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt;5&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt;main&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt;st&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;elem/&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt;Cumming&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt; GA&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt; 30040&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt;Kirk Evans&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;/row&amp;gt;&lt;br&gt;&amp;lt;row&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt;2&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt;13&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt;elm&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt;st&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;elem/&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt;Anywhere&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt; NJ&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt; 07825&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt;Bob&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;elem&amp;gt;Smith&amp;lt;/elem&amp;gt;&lt;br&gt;&amp;lt;/row&amp;gt;&lt;br&gt;&amp;lt;/root&amp;gt;&lt;br&gt;&lt;br&gt;which is quite different to what was intended. The problem I think is that the CR and LF are not interpreted correctly according to how you've written this script. They are seen as whitespace and included in the string pattern.</description></item><item><title>I'm really shocked that I'm the only person who spotted this ...</title><link>http://blogs.msdn.com/kaevans/archive/2003/04/17/5780.aspx#157138</link><pubDate>Wed, 16 Jun 2004 17:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:157138</guid><dc:creator>Paul Owen</dc:creator><description>The correct way is to declare the LF entity properly at the top of the document. Like this:&lt;br&gt;&lt;br&gt;&amp;lt;xsl:variable name=&amp;quot;LF&amp;quot; select=&amp;quot;'&amp;amp;#010;'&amp;quot;/&amp;gt;&lt;br&gt;&lt;br&gt;and then reference it in the document. So instead of this:&lt;br&gt;&lt;br&gt;&amp;lt;xsl:with-param name =&amp;quot;StringToTransform&amp;quot; select =&amp;quot;substring-before($StringToTransform,' ')&amp;quot; /&amp;gt;&lt;br&gt;&lt;br&gt;you have this:&lt;br&gt;&lt;br&gt;&amp;lt;xsl:with-param name =&amp;quot;StringToTransform&amp;quot; select =&amp;quot;substring-before($StringToTransform,$LF)&amp;quot; /&amp;gt;&lt;br&gt;&lt;br&gt;which will give the desired output as outlined in the article. I'd like to be on a Microsoft Corporation salary like the author, but obviously I'm too bothered about accuracy of code ... ;)</description></item><item><title>re: Convert CSV to XML</title><link>http://blogs.msdn.com/kaevans/archive/2003/04/17/5780.aspx#157402</link><pubDate>Wed, 16 Jun 2004 21:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:157402</guid><dc:creator>Kirk Allen Evans</dc:creator><description>This post and others containing XSLT have been problematic.  The HTML WYSIWYG editor used for .Text at the time of this post's writing automatically converted character entities, and ScottW added code in the backend to strip and replace markup when he saw that people were adding markup that altered the presentation of the main feed on &lt;a target="_new" href="http://weblogs.asp.net"&gt;http://weblogs.asp.net&lt;/a&gt;.  In fact, if you replace all instances of ' ' with &amp;amp;#xA; as the article originally included, the XSLT works as advertised (instead of creating a parameter, I referenced the character entity inline).  I did not go back and alter the post to accomodate this change in .Text.</description></item><item><title>re: Convert CSV to XML</title><link>http://blogs.msdn.com/kaevans/archive/2003/04/17/5780.aspx#164397</link><pubDate>Thu, 24 Jun 2004 09:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:164397</guid><dc:creator>Piyush</dc:creator><description>How do I embed the &amp;quot;&amp;lt;root&amp;gt;&amp;quot; tags in the .csv file, using javascript or XSL?&lt;br&gt; Plus, how do I use the aforementioned stylesheet with the .csv file? Since there's no XML declartion in the .csv file (&amp;lt;?xml version...), I'm pretty confused about how to implement all this to convert my csv into xml. </description></item><item><title>re: Convert CSV to XML</title><link>http://blogs.msdn.com/kaevans/archive/2003/04/17/5780.aspx#174073</link><pubDate>Tue, 06 Jul 2004 19:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:174073</guid><dc:creator>Paul Owen</dc:creator><description>Yes, that fixed it Kirk - nice job.&lt;br&gt;&lt;br&gt;It's a nice little script. &lt;br&gt;&lt;br&gt;It's a small point I've found whilst using it, that if you're processing UNIX and Windows-generated CSV files, it's more reliable to delimit rows on the CR 013 character than the LF 010.&lt;br&gt;&lt;br&gt;I have a variable at the top of the adapted XSLT as follows:&lt;br&gt;&lt;br&gt;&amp;lt;xsl:variable name=&amp;quot;CR&amp;quot; select&amp;quot;'&amp;amp;#013;'&amp;quot;/&amp;gt;&lt;br&gt;&lt;br&gt;...&lt;br&gt;&lt;br&gt;&amp;lt;xsl:if test=&amp;quot;contains($StringToTransform,$CR)&amp;quot;&amp;gt;&lt;br&gt;&lt;br&gt;...&lt;br&gt;&lt;br&gt;which doesn't care if CR (UNIX) is used or CRLF (DOS/Windows).</description></item></channel></rss>