Help to convert XML to CSV

Apologies if this has already been covered in this site somewhere, I did try looking but without any success. I am new to the whole XML thing, very late starter, and have a requirement to convert an XML fiule to a CSV fomat. I am crrently working on a Solaris OS. Does anyone have any suggestions, code samples or sites that can get me on the first rung of the ladder.

If you can use Perl, you can read data from XML file using XML::Simple module, and then create csv file using that data

This is not as simple to do as converting from CSV to XML.

First you have to remove the declarations, root element and comments, then for each "record" figure out which elements should be columns and which "record" has the greatest number of columns. Unless it is a very simple XML document, it may not be easily parsed.