I need to merge multiple (100's) of XML files into one file that I can import into a MySQL database.
There are two parts to this:
1) I need to add a tag for the file name
2) I need the output file to contain all the data plus the new tag for each file that is merged
So for example I have a directory that contains:
2009-09-08-09-21-29_115_11
2.xml
2009-09-08-09-21-29_115_11
2.wav
2009-09-08-09-21-03_702869
1049_115.x
ml
2009-09-08-09-21-03_702869
1049_115.w
av
2009-09-08-09-18-03_100_11
2.xml
2009-09-08-09-18-03_100_11
2.wav
etc... I need the xml files combined and then a new tag called <file_name> created for each
So for the 3 xml files above the output would be:
<recording_info>
<recording_tag>All Record</recording_tag>
<recorded_call_id>36329</r
ecorded_ca
ll_id>
<recorder_cid />
<recorded_cid>Distribution
<112></recorded_cid>
<recorder_account_id />
<recorded_account_id>1111<
/recorded_
account_id
>
<from_account_id>1113</fro
m_account_
id>
<from_caller_id>John Segrest <115></from_caller_id>
<to_account_id>1111</to_ac
count_id>
<to_caller_id>Distribution
<112></to_caller_id>
<duration>99</duration>
<date_created_ts>2009-09-0
8 09:21:29.617108</date_crea
ted_ts>
<date_created_secs>1252426
890</date_
created_se
cs>
<file_name>2009-09-08-09-2
1-29_115_1
12.wav</fi
le_name>
</recording_info>
<recording_info>
<recording_tag>All Record</recording_tag>
<recorded_call_id>36328</r
ecorded_ca
ll_id>
<recorder_cid />
<recorded_cid>John Segrest <115></recorded_cid>
<recorder_account_id />
<recorded_account_id>1113<
/recorded_
account_id
>
<from_account_id>0</from_a
ccount_id>
<from_caller_id>GAGE AND GAGE L <7028691049></from_caller_
id>
<to_account_id>1113</to_ac
count_id>
<to_caller_id>John Segrest <115></to_caller_id>
<duration>36</duration>
<date_created_ts>2009-09-0
8 09:21:03.232146</date_crea
ted_ts>
<date_created_secs>1252426
863</date_
created_se
cs>
<file_name>2009-09-08-09-2
1-03_70286
91049_115.
wav</file_
name>
</recording_info>
<recording_info>
<recording_tag>All Record</recording_tag>
<recorded_call_id>36327</r
ecorded_ca
ll_id>
<recorder_cid />
<recorded_cid>Kimberly Miles <109></recorded_cid>
<recorder_account_id />
<recorded_account_id>1107<
/recorded_
account_id
>
<from_account_id>1107</fro
m_account_
id>
<from_caller_id>Kimberly Miles <109></from_caller_id>
<to_account_id>-1</to_acco
unt_id>
<to_caller_id>95475425</to
_caller_id
>
<duration>160</duration>
<date_created_ts>2009-09-0
8 09:18:34.037292</date_crea
ted_ts>
<date_created_secs>1252426
714</date_
created_se
cs>
<file_name>2009-09-08-09-1
8-34_109_9
5475425.wa
v</file_na
me>
</recording_info>
The original XML file contains everything EXCEPT the <file_name> line. The file name is always the same as the XML file name except that the extension is wav (always)
Then i need the original xml files either deleted or move to a different location like a bak folder or something. All the files are in the same directory and will remain in the same directory.