[Chicago] Need Python -2.4.3 help
Jordan Bettis
jordanb at hafd.org
Mon Mar 17 16:57:39 CET 2014
You could use a version of lxml that supports 2.4.3 and then parse the
XML with the ElementTree API
http://lxml.de/tutorial.html
On 03/17/2014 09:13 AM, Harry aman wrote:
> Hi,
>
> I'm new to Python. The installed Python version is 2.4.3 in
> Linux and our admins are not willing to upgrade it due to other
> comparability issues.
>
> The issue is related to reading XML file and convert it to a
> txt file for further process.
>
> Here's the code example.
> #read XML file and convert into text file for further process
> from xml.dom.minidom import parse, parseString
> dom=parse('/mnt/usr/Test.xml')
> outf = open ('/mnt/usr/Test.txt','w')
> attr_list = [
> 'col1',
> 'col2',
> 'col3',
> 'col4'
> ]
> for row in dom.childNodes[0].getElementsByTagName('z:row'):
> for attr in attr_list:
> if attr in row.attributes.keys():
> outf.write(row.attributes[attr].value.encode("utf-8")+"\t")
> else: outf.write("\t")
> outf.write("\n")
> outf.close()
>
> I didn't see any good example to do this. Please let me know your
> suggestions.
>
> Thanks in Advance.
>
> Regards
>
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> https://mail.python.org/mailman/listinfo/chicago
>
More information about the Chicago
mailing list