XML transfromation to .CSV

They have: 32 posts

Joined: Jan 2001

I need to transform XML to .CSV. Any ideas, tutorials, code?

I think I want to use XSL.

Thanks!

They have: 32 posts

Joined: Jan 2001

I decided to use an XSL transformation to transform the XML to .CSV. Excel is the default program to open files of this type. If you put these files in your wwwroot/testxsl
directory then run the testxslcsv.asp file you will see the XML in I.E. via response.write. The file will be saved to your C Drive using the File System Object. Click on the file and Excel will open it.

Sample XML I have named it TestXSLCSV.xml

<?xml version="1.0" ?>

Sample XSL I have named it TestXSLCSV.xsl

User Name,Address,City,State

,,,

Sample ASP page I have named it TestXSLCSV.asp

<?php
   Dim fso
, MyFile

   sourceFile
= Server.MapPath("TestXSLCSV.xml")
  
Set source = CreateObject("Microsoft.XMLDOM")
  
source.async = false
   source
.load(sourceFile)

  
styleFile = Server.MapPath("TestXSLCSV.xsl")
  
Set style = CreateObject("Microsoft.XMLDOM")
  
style.async = false
   style
.load(styleFile)
  
  
FinalXML = source.transformNode(style)

   
Response.Write FinalXML


   Set fso
= CreateObject("Scripting.FileSystemObject")
  
Set MyFile = fso.CreateTextFile("c:\TestXSLCSV.csv", True)
  
MyFile.WriteLine(FinalXML)
  
MyFile.Close
?>

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Thanks for the code!

They have: 32 posts

Joined: Jan 2001

No problem!

I just wish I had more to share. I really appreciate this forum and think you guys are doing a wonderful job!!!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.