I am working on a Perl script which needs to populate an XML file based on user input. The user would provide a country name and a city name. If he/she provides: japan and e, I need to populate that in the japan tag - but as the last entry. How best can I achieve this? The cities in country tag can be many. How can I add a city as a last tag inside corresponding country tag?
How can I reach at the end of relevant country tag each time I need to add a city?
PS: I am not using any in-built data structures to store data. I am just adding dumb lines in the file.
Samlple output XML file:
<country name="japan-">
<city>a</city>
<city>b</city>
<city>c</city>
<city>d</city>
</country>
<country name="china-">
<city>aa</city>
<city>bb</city>
<city>cc</city>
<city>dd</city>
</country>
I've a more concrete question, Change an XML file content via Perl script.