Print

Print


> I have around 1400 xml files that I am trying to copy into one xml file so that I can then pull out three elements from each and put into a single csv file.

What are three elements you want to pull out of each XML file, and
what do you want the CSV file to look like?

Your XML files are pretty flat, and  if I understand the question
correctly, then it is all but trivial to extract your three elements
as a line of CSV.  Consequently I suggest foregoing the concatenation
of all the XML files into a single file. Such only adds complexity.
Instead I suggest:

 1. Put all XML files in a directory
 2. For each XML file, process with XSL
 3. Output a line of CSV
 4. Done

#!/bin/bash

# xml2cvs.sh - batch process a set of XML files

# configure (season the value of XSLTPROC to taste)
XSLTPROC=/usr/bin/xsltproc
XSLT=xml2csv.xsl

# process each file
for FILE in ./data/*.xml

 # do the work
 $XSLTPROC  $XSLT $FILE

end

# done
exit

 $ mkdir ./data
 $ cp *.xml ./data
 $ ./xml2csv.sh > data.csv
 $ open data.csv

Just about all that is missing is:

 * what elements do you want to extract, and
 * what do you want the CSV to look like

--
ELM