CSV with multiple header rows to XML

A

Alan_C

Hi,
Using Perl I converted a few simple, single header, csv to xml.

But I have a csv file that has:

Header,row,#1
data_row,under,header_1
nuther_data_row,under,header_1
Header,row,number,two
data_row,under,header,2
nuther_data_row,under,header,2


Note that the header rows differ in their number of columns.

Does xml support multiple and somewhat/slightly differing header rows as
well as corresponding/matching format data like the example above? If
yes, what does an xml equivalent of the above csv example look like?

Or would it be up to a style sheet to coordinate/designate which rows
in the xml are the header rows?

This csv file has near 6 or 7 different header rows with corresponding
data row/columns as per the example above.

This csv file converts to html alright. The html is merely tables with
every so often is a new header row with corresponding data rows below
each header.

But, so far, my use of Perl to attempt this particular csv to xml fails.

I suspect that this AnyData.pm Perl module grabs the first header row,
expecting it to be the only header row. Anyways, it dies, reporting
"invalid xml", produces an empty output file.

Thanks.
 
J

Joe Kesselman

Alan_C said:
Does xml support multiple and somewhat/slightly differing header rows

XML itself has no concept of "rows", header or otherwise. That would be
defined by the language you use XML to implement.
what does an xml equivalent of the above csv example look like?

Whatever the person who designs that particular XML markup wants it to
look like. There are multiple good solutions here depending on what you
actually want to do with the data. One would be to borrow HTML's table
tagging and extend it as necessary to support the sub-headers; another
would be to treat it as a table of tables each having their own headers;
or you might want to do something completely different.
Or would it be up to a style sheet to coordinate/designate which rows
in the xml are the header rows?

The stylesheet is written to match the specific XML markup.
But, so far, my use of Perl to attempt this particular csv to xml fails.
I suspect that this AnyData.pm Perl module

Since you're using someone else's code, check the documentation for
their code to find out whether it supports this. If not, you may need to
modify that solution or write your own.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top