Hi,
I have a number of xml files which need to be converted into csv files - which would be the best method to do this using C (I have use of an oracle db if need be)?
Ta,
Manny
Hi,
I have a number of xml files which need to be converted into csv files - which would be the best method to do this using C (I have use of an oracle db if need be)?
Ta,
Manny
So is doing this in C a requirement, or just a suggestion on your part because it's the only language you know?
Because my first reaction to this problem would be to use Perl.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Perl sounds like an excellent choice for this - I'm no Perl expert, but translating text from one format to another is typically something that Perl does REALLY well.
Alternatively, try to find some XML library that you can use with C...
--
Mats
http://expat.sourceforge.net/ is one such library, which coincidentally is also available via a perl module.
Unless this is homework, I see no reason to write this in C.
For me, the only issue is how long does it take to write the program. It might take days of messing about with C's primitive string handling, and for what - a program you run once on a handful of files and then throw away?
To me, this is a 5-minute lash-up in Perl, coupled with a quick test to make sure it's likely to run in minutes rather than weeks. Then set it going on the whole lot and go and have lunch.
Most of the programs time is going to be spent in file I/O anyway, so the performance improvement of C isn't going to be that great.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
If you are "strong" at C string handling, you will probably be ok with using C. If you struggle to use strcpy, strstr and such functions, then I would suggest that learning Perl is no more difficult than to write the code and fix the inevitible bugs in C.
A few google finds:
http://www.fredshack.com/docs/perl.html
http://www.rexswain.com/perl5.html
Guide to Perl regular expressions (this will help you parse/translate XML):
http://www.biotek.uio.no/EMBNET/guides/guideRegExp.pdf
--
Mats
When I did some XML / Perl stuff recently, I cribbed stuff from here - http://www.xml.com/lpt/a/313
Once you've got to the stage of printing out start/end elements and attribute/value pairs, then it should be pretty easy to get to reformatting the data you want.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Thanks.
I will stick with using C for now. Perl does look like a good option but I'm a little hesitant to try it out as I'd like more experience of C at present - but Perl is definately something I will look in to for the future.
My language of choice for this task would actually be XSLT.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law