Re: [xsl] csv data to xml

Subject: Re: [xsl] csv data to xml
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Tue, 25 Jun 2013 14:07:25 +0100
On 25 June 2013 13:46, henry human <henry_human@xxxxxxxx> wrote:
> Hi guys
> Need your help:
>
> How get this csv data to xml using xslt:
>
>
> a) CSV
> USA,AA,Comp. 1,U,012345,L987
> USA,BB,Comp.2,Z,034567888888,F098
> USA,CC,Comp 3,M,034847474747,F098
> //more csv rows.
>
>
>
> b) xml (result)
>
> <?xml version="1.0" encoding="UTF-8"?>
> <MemberList">
>  <Segment>
>   <Country>USA</Country>
>   <Draft>AA</Draft>
>   <Description>Comp.1 </Description>

Use unparsed-text() to read the csv, then use tokenize() to split it
into lines, iterate over each line outputting a <Segment>, then
tokenize() the $line into $tokens, and use fill-in-the-blanks style to
populate the elements.



-- 
Andrew Welch
http://andrewjwelch.com

Current Thread