🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.xml
Article #52

CSV to XML help

#52
From: Nicholas Ring
Date: Mon, 14 Apr 2008 23:46
69 lines
2295 bytes
Hello,

I have a CSV file which I need to convert to XML, in a particular
format. It has been suggested that I use a XML template. I have never
used a template before, nor have I used XML before - great start, eh?

I have been given a sample XML and it seems that a part of the CSV will
need to be place into multiple <ITEM> </ITEM> section.

I know that in the future different CSVs files will be required to
created different XML structures, I would like some [generic] code to
take an template XML and populate the XML before sending it on, based on
the CSV definition.




For example (simplified but does cover what I need to do) :


If the header of the CSV is:

  memberid, sell1, sell2, sell3, buy1, buy2, buy3

the XML will need to be something like:

<account>
  <identifier>[memberid]</identifier>
</account>
<instructions>
  <instruction>
    <type>sell</type>
    <items>
      <item>
        <code>[sell1]</code>
      </item>
      <item>
        <code>[sell2]</code>
      </item>
      <item>
        <code>[sell3]</code>
      </item>
    </items>
  <instruction>
  <instruction>
    <type>buy</type>
    <items>
      <item>
        <code>[buy1]</code>
      </item>
      <item>
        <code>[buy2]</code>
      </item>
      <item>
        <code>[buy3]</code>
      </item>
    </items>
  <instruction>
</instructions>

Where the fields in [] are from the CSV


Any starting points, clues, components, URLs, anything...?

Many thanks in advance,
Nick

-- 
Technical Details
Message-ID: <xn0foyk0m4yjlu000@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f5d9b,c90ea005ed233f98,start
X-Google-Attributes: gidf5d9b,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Nicholas Ring" <Nicholas.Ring@smf.com.au>
Subject: CSV to XML help
Newsgroups: borland.public.delphi.xml
User-Agent: XanaNews/1.18.1.6
Message-ID: <xn0foyk0m4yjlu000@newsgroups.borland.com>
X-Ref: newsgroups.borland.com ~XNS:00000087
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
NNTP-Posting-Host: 203.47.115.45
Date: 14 Apr 2008 16:46:51 -0700
X-Trace: newsgroups.borland.com 1208216811 203.47.115.45 (14 Apr 2008 16:46:51 -0700)
Lines: 70
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail