View Full Version : [SOLVED] Extract specifc XML tags using Perl or Similar

November 20th, 2008, 05:11 AM
Hi All,

Im no programmer but Im trying to do something which I know should be simple, Ive toyed around a tiny bit with bash scripting, sed and perl , and Im terrible at it.

Ive got a raw xml file which has recurring information.
Im trying to grab key fields using the tags and place them on a seperate comma or tab delimited file,
I know theres probably a number of posts here that may do the trick and squillions on the internet, but I cant seem to find anything useful. If anyone has any examples or good howto guides.

Heres a very crude example

<CountryName>United States</CountryName>

Extract Firstname Country name code and locality
This will give


And on until there is no more information.

November 20th, 2008, 05:15 AM
Python with ElementTree (lxml.etree, since Py2.5) is the easierst way, by far.

November 20th, 2008, 06:21 AM

Thanks for the info.
Ill kick the tires on that tomorrow and see how it shakes out.


December 2nd, 2008, 05:55 PM

I managed to get a workable solution in place using xml2csv, and even better there is a version available for the Windows OS, which allows me to get someone else to do this who is not linux savvy.

THe tricky part for me was coming up with the format.txt file to aprse what I needed , but now it is operational.