Re: XML parsing with python

2009-08-18 Thread Stefan Behnel
inder wrote: On Aug 17, 8:31 pm, John Posner jjpos...@optimum.net wrote: Use the iterparse() function of the xml.etree.ElementTree package. http://effbot.org/zone/element-iterparse.htm http://codespeak.net/lxml/parsing.html#iterparse-and-iterwalk Stefan iterparse() is too big a hammer for

Re: XML parsing with python

2009-08-18 Thread Stefan Behnel
John Posner wrote: Use the iterparse() function of the xml.etree.ElementTree package. iterparse() is too big a hammer for this purpose, IMO. How about this: from xml.etree.ElementTree import ElementTree tree = ElementTree(None, myfile.xml) for elem in tree.findall('//book/title'):

Re: XML parsing with python

2009-08-18 Thread inder
On Aug 18, 11:24 am, Stefan Behnel stefan...@behnel.de wrote: inder wrote: On Aug 17, 8:31 pm, John Posner jjpos...@optimum.net wrote: Use the iterparse() function of the xml.etree.ElementTree package. http://effbot.org/zone/element-iterparse.htm

Re: XML parsing with python

2009-08-18 Thread Stefan Behnel
inder wrote: Is lxml part of standard python package ? I am having python 2.5 . No, that's why I suggested ElementTree first. I might not be able to use any additional package other than the standard python . Could you please suggest something part of standard python package ? No, there

XML parsing with python

2009-08-17 Thread inder
Hi All, I am new to xml . I need to parse the xml file . After reading and browsing on the web , I could get much help . I guess SAX would be better suited for my requirement . Could some juct provide me a sample python code so that I can execute it and see how the parsing actually happens .

Re: XML parsing with python

2009-08-17 Thread Stefan Behnel
inder wrote: I am new to xml . I need to parse the xml file . After reading and browsing on the web , I could get much help . I guess SAX would be better suited for my requirement . That's a common misconception. Could some juct provide me a sample python code so that I can execute it

Re: XML parsing with python

2009-08-17 Thread John Posner
Use the iterparse() function of the xml.etree.ElementTree package. http://effbot.org/zone/element-iterparse.htm http://codespeak.net/lxml/parsing.html#iterparse-and-iterwalk Stefan iterparse() is too big a hammer for this purpose, IMO. How about this: from xml.etree.ElementTree import

Re: XML parsing with python

2009-08-17 Thread inder
On Aug 17, 8:31 pm, John Posner jjpos...@optimum.net wrote: Use the iterparse() function of the xml.etree.ElementTree package. http://effbot.org/zone/element-iterparse.htm http://codespeak.net/lxml/parsing.html#iterparse-and-iterwalk Stefan iterparse() is too big a hammer for this