|
|
Need to convert XML to CSV in VB6?Don't want to spend the rest of your life learning how to do it? Read the "Least You Need to Know" guide below CSV is probably the mostly widely supported format for importing data to traditional applications. XML however has become increasingly fashionable even when it's perhaps not the best format for this type of import. This quick guide demonstrates how to convert a basic XML file to CSV. It will convert all the XML nodes found so you don't need to worry about how many child nodes exist in the XML file. All you need to specify is the root node name and the child node you want to convert. The example shows the XML file we want to convert, the XSL file that controls the conversion, the CSV output produced and the VB6 code used to achieve these results. Please remember that this is the very least you need to know but it should serve to get you started with a minimum of pain. To do anything more you will need to spend some time learning about all those things you really didn't want to know about. Quick Intro An XSL file is a template that tells the XML processor how to translate an XML file. If your needs are fairly basic it's a whole lot easier than writing code to process the XML file. If you have lots of nested elements you'll probably be better of writing code to handle the XML file. Our example simply specifies the XML to be converted, the XSL file to be used and writes out the CSV file. There are some limitations of this example. It doesn't pick up the Stock Code from the Stock record so you want probably want to make sure that there was a separate StockCode element. It also won't cope with sub nodes of the stock record. Before you start You must add a reference to Microsoft XML vsn 3.0 to your project. There are lots of versions of XML but this version appears to be available on all Microsoft Windows versions. If you use a later version you will need to install the appropriate MSI file on your clients machines.
For more information please try the following links
|
|
Copyright © 2005 - 2009 Steve Blencowe Systems LimitedLast Updated 14/06/2010
|