Page 1 of 1

csv to xml

Posted: Wed Aug 20, 2008 6:48 am
by uirp03
Hi. I need to convert the csv file separated by '|' into a xml file format. May I know how to change the xml name tag?

Input csv file
Person|Name|Carol Lee
Person|Gender|Female

Info|Height|1.68|m
Info|Weight|55|kg

The sample output XML file
<Root>
<Person>
<Name>Carol Lee</Name>
<Gender>Female</Gender>
</Person>
<Info>
<Height>1.68<Height>
<Unit>m</Unit>
<Weight>55</Weight>
<Unit>kg</Unit>
</Info>
</Root>

Re: csv to xml

Posted: Wed Aug 20, 2008 2:47 pm
by sorin_ristache
Hello,

Oxygen has an import action that can be applied to CSV files and the XML tag names of the result XML file can be configured in the Import Settings panel of the dialog but the text values must be separated by comma, semicolon, tab or space. You cannot generate the XML file that you posted from the input text file that separates the text values with '|'. The XML tags must be specified only once on the first row of the text file instead of once for every text value. For your example the input file should be:

Code: Select all

Name, Gender, Height, Unit, Weight, Unit
Carol Lee, Female, 1.68, m, 55, kg
The XML file will be:

Code: Select all

<root>
<row>
<Name>Carol Lee</Name>
<Gender>Female</Gender>
<Height>1.68</Height>
<Unit>m</Unit>
<Weight>55</Weight>
<Unit>kg</Unit>
</row>
</root>
and it can be transformed to your final XML format with an XSLT transformation.


Regards,
Sorin

Re: csv to xml

Posted: Mon Aug 25, 2008 6:27 am
by uirp03
hi, could anyone provide the xslt to convert to the final xml format? Thanks.