Fwd: xml to mysql (vice versa ) too

Stefan Behnel stefan_ml at behnel.de
Tue Jun 24 18:43:35 CEST 2008


> Le Tuesday 24 June 2008 07:08:46 swapna mudavath, vous avez écrit :
>> can anybody help me in this....
>>
>> -swapna
>>
>> ---------- Forwarded message ----------
>> From: swapna mudavath <swapna.nitw at gmail.com>
>> Date: Mon, Jun 23, 2008 at 5:27 PM
>> Subject: xml to mysql (vice versa ) too
>> To: Python-list at python.org
>>
>>
>> Hi,
>>
>> I need to write a python script to store data which is in XML to MYSQL and
>> even vice versa....
>> what should be the approach?
>> i am able to establish a connection,create tables and insert data .....
>> but how to read an xml file and store in MYSQL....
>> my XML structure is like
>>
>> <list  title=" xyz", id = "1",........>
>>     <item name="  abc" ,pos="1",........>
>>     </item>
>>     <item  name =" hgdf", pos ="3",......>
>>     </item>
>>    .
>>    ....
>>    ...
>> </list>
> 
> This is not valid xml, there is no commas in attribute list in xml.

Yes, so maybe you should tell us where you got this from and if you are in the
position to change this?


>> can somebody please help me......i am really confused!!!!!!

Try lxml.objectify. It lets you work with XML as it if were simple Python objects.

http://codespeak.net/lxml/objectify.html

That should allow you to easily extract data from the XML and to generate XML
from the data you get from MySQL.

Stefan



More information about the Python-list mailing list