I want to make a command line program that will hopefully work on both Windows and Linux. I want to use Python since it is my programming language of choice. The goal is the make the program take file name as an argument, and output the information from the file in a different format. In this case XML -> CSV and CSV -> XML.
What is the best way to do this?
I know there are XML and CSV parsers in Python, like xml.parsers.expat and csv libraries. I want the program to be robust, so that perhaps it could output in other formats, like .sql or something. Would be beneficiary to convert the data into a standard format first? Like JSON? Then the output file could be made into other formats in necessary.
Thanks.
EDIT::
<level1 id ='' attr1='' attr2=''>
<level2 id ='' attr1='' attr2=''>
<type1 id ='' attr1='' attr2=''>
</type1>
<type2 id ='' attr1='' attr2=''>
</type2>
</level2>
<level2 id ='' attr1='' attr2=''>
<type2 id ='' attr1='' attr2=''>
</type2>
</level2>
</level1>
This is the XML format. Notice the type1 and type2 inside the level2. Now how should I represent this line by line in a csv?
EDIT #2:
I guess this question comes down to standard way to convert between a tree-like data structure and a grid structure. I ended up making a nested list in python, like JSON but didn't used the JSON structure. I wonder if there is a good algorithm in general for making this conversion?
</level1 id ='' attr1='' attr2=''>is not a valid xml.