Hi, I'm a newbie to XML. I've found some resources for converting CSV to XML, and vice versa. But they seem to cover only one kind of XML - where the data is enclosed in tags (no data as tag attributes).
I'm wondering if there is a way to do a conversion from CSV to XML and XML to CSV in the following formats. For XML to CSV, I know you can use XSLT but I don't know how to adequately write the XSLT.
Sample XML Format (this is what I'm given):
<input OrderID=1232 CustomerID=XYZ>
<group id=1>
<Item ProductID=121>
<OrderLineID>1</OrderLineI
D>
<Units>1</Units>
<NumOfSites>1</NumOfSites>
<Type>1</Type>
<Timeperiod>45</Timeperiod
>
</Item>
<Item ProductID=122>
<OrderLineID>2</OrderLineI
D>
<Units>1</Units>
<NumOfSites>1</NumOfSites>
<Type>2</Type>
<Timeperiod>45</Timeperiod
>
</Item>
</group>
<group id=2>
<Item ProductID=123>
<OrderLineID>3</OrderLineI
D>
<Units>1</Units>
<NumOfSites>1</NumOfSites>
<Type>1</Type>
<Timeperiod>45</Timeperiod
>
</Item>
<Item ProductID=124>
<OrderLineID>3</OrderLineI
D>
<Units>1</Units>
<NumOfSites>1</NumOfSites>
<Type>1</Type>
<Timeperiod>45</Timeperiod
>
</Item>
</group>
</input>
Sample CSV format (this format, I can specify/rearrange. Below is what I think is best in terms of CSV format).
productID, orderLineID, unit, numSites, type, period, orderID, customerID, groupID
121,1,1,1,45,1232,XYZ,1
122,2,1,1,2,45,1232,XYZ,1
123,3,1,1,1,45,1232,XYZ,2
124,3,1,1,1,45,1232,XYZ,2
How can I convert from one format to the other and vice versa, if possible? In terms of implementation, I need a command line tool. Tool could be in Java, C/C++, .NET/C#, VBScript, or Perl. Something customizable would be preferred so I can adapt it when changes occur, so I'd like to have the source code, not just the binary.
Start Free Trial