XML/encoding/prolog/python hell...

fscked fsckedagain at gmail.com
Wed Mar 28 19:40:59 CEST 2007

I am a beginning pythoner and I am having a terrible time trying to
figure out how to do something that (it would seeme to me) should be
fairly simple.

I have a CSV file of unknown encoding and I need to parse that file to
get the fields <--- DONE
I need to create an xml document that has the proper prolog and
namespace information in it. <--- NOT DONE
I need it to be encoded properly<--- Looks right in IE, not right in
any other app.

I should say that I have googled my butt off, tried ElementTree,
CSV2XML, and various other things and cannot get any of them to work.

A sample of the output I am looking for is as follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:boxes xmlns:ns2="Boxes">
	<ns2:box id="9" mac="333333" d_a="2006" hw_ver="v1.1" sw_ver="3"
pl_h="No Data" name="Lounge" address="here" phone="555-5555"
country="US" city="LA"/>
	<ns2:box id="7" mac="444444" d_a="2005" hw_ver="v1.0" sw_ver="3"
pl_h="No Data" name="MyHouse" address="there" phone="555-5556"
country="US" city="New York"/>

Is there some fundamental thing I am not getting? I cannot get
'tostrings' to work in ElementTree and I cannot figure the prolog out.

I posted a similar message back in January, but haven't had much luck.

No I haven't been trying to do this since January, more important
things came up at work and I have just revived this. :)

More information about the Python-list mailing list