Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What is the ideal way to parse an .xml file into a .csv file that I could include with my shell scripts. I know bash cant do it but I'm unsure if I should try in awk or sed. I imagine a language would be the best solution such as python but I do not know python nor have I touched it.

share|improve this question
5  
As has been argued before parsing tag structured files warrants a real parser. You could e.g. use Ruby and use Nokigiri to parse XML and the class CSV to output CSV. Also, please add a simple example of input and output so that it understandable what you expect from an answer. –  N.N. Feb 21 '13 at 16:36
    
thanks I didn't find that from my search –  Darth_Vader Feb 21 '13 at 16:41

2 Answers 2

up vote 3 down vote accepted

You could use Xmlstarlet (AKA xml) as a XSLT transformer and write a specific CSV transform as mentioned here http://stackoverflow.com/a/952389/1481060

share|improve this answer
echo "Hello"
java -Xms512m  -Xmx3048m -jar xml2csv-conv.jar -k attr_list 
source_file.xml destination_file.nnmpa1.csv
share|improve this answer
    
Where does one get this xml2csv-conv.jar file? –  Warren Young Jun 19 at 10:51
    
Although the code is appreciated, it should always have an accompanying explanation. This doesn't have to be long but it is expected. –  peterh Jun 19 at 10:59
1  
I am deleting this since it's just a random command with no explanation or any information on what it does, how to run it and where to find the requisite jar file. –  terdon Jun 19 at 11:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.