Use Ruby:
Code:
$out_count = 0
def process( str )
str.strip!
continent,country,city,id = str[1..-2].split(/","/)
$out_count += 1
File.open( "output_#{ $out_count }.xml", "w" ){|handle|
handle.puts <<"HERE_DOC"
<?xml version="1.0"?>
<!DOCTYPE ALR [
<!ENTITY gt "&gt;">
<!ENTITY lt "&lt;">
<!ENTITY quot "&quot;">
]>
<datafile>
<info ID="#{ id }">
<info1>#{ continent }</info1>
<info2> </info2>
<info3>#{ country }</info3>
<info4>#{ city }</info4>
<info5>some fixed data</info5>
<info6> </info6>
<info7> </info7>
<info8>some fixed data</info8>
<info9>some fixed data</info9>
<info10>some fixed data</info10>
<info11>some fixed data</info11>
</info>
<action>
<attributes>
<attributkey id="011" >N</attributkey>
<attributkey id="106" >N</attributkey>
<attributkey id="114" >N</attributkey>
<attributkey id="119" >N</attributkey>
</attributes>
<comment> </comment>
</action>
</datafile>
HERE_DOC
}
end
# Discard 1st line of file.
gets
# Read rest of file.
while gets
process( $_ )
end
Save this code in file "make_xml.rb".
Run it with
ruby make_xml.rb my_input_file
The output files are named "output_1.xml", etc.