how to retrive data from odt xml file in python?

A forum for general discussion of the Python programming language.

how to retrive data from odt xml file in python?

Postby vampo650 » Tue Mar 26, 2013 4:32 am

I am successfully retreving the odt xml file in python but I have no idea how to pull xml file data?

Any techniques are there for pulling the odt xml file data.

Here my code for extracting odt xml file

#!/usr/lib/python2.7

import sys, zipfile

if len(sys.argv) < 2:
print "input.odt & output.xml"
sys.exit(0)

content=""
myfile = zipfile.ZipFile(sys.argv[1])
listoffiles = myfile.infolist()
for s in listoffiles:
if s.orig_filename == 'content.xml':
fd = open(sys.argv[2],'w')
content = myfile.read(s.orig_filename)
fd.write(content)
fd.close()
vampo650
 
Posts: 9
Joined: Wed Mar 20, 2013 6:32 am

Re: how to retrive data from odt xml file in python?

Postby micseydel » Tue Mar 26, 2013 5:48 am

Use code tags.

Google "python xml". After that, come back with more specific questions.
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1229
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 3 guests