Lassie has asked for the wisdom of the Perl Monks concerning the following question:

I am a bit puzzled as to how to create an XML file structured according to a DTD from a Tab delimited text file (with the first row being column headers, which are also the names of the attributes and elements. The problem is using the DTD to match up the structure as in which columns are attributes (instead of seperate elements) to the elements of which column (each row being a seperate record). I can't seem to get any perl to xml module to do this, and it can't be hardcoded (needs to work with any DTD/TDF.) Would it be possible to do this without a module?

Replies are listed 'Best First'.
Re: Tab Delimited File > XML via DTD?
by mirod (Canon) on Feb 26, 2003 at 16:59 UTC

    It might be quite difficult to do it straight from the DTD, maybe a config file that extracts the interesting info from the DTD might be convenient. You can have a look at XML::DTDParser, or even at XML::Parser for the DTD info, and at AnyData to read the CSV and output the XML.

Re: Tab Delimited File > XML via DTD?
by valdez (Monsignor) on Feb 26, 2003 at 17:03 UTC

    Did you try with XML::CSV? No help for DTD, but you can rearrange fields following DTD rules before running your converter.

    Ciao, Valerio