csv to xml

Oxygen general issues.
uirp03
Posts: 3
Joined: Wed Aug 20, 2008 6:42 am

csv to xml

Post 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>
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: csv to xml

Post 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
uirp03
Posts: 3
Joined: Wed Aug 20, 2008 6:42 am

Re: csv to xml

Post by uirp03 »

hi, could anyone provide the xslt to convert to the final xml format? Thanks.
Post Reply