[BangPypers] parsing xml
Smrutilekha Swain
smrutilekha at gmail.com
Mon Aug 1 10:25:20 CEST 2011
by using lxml...for example-:
from lxml import etree
content = etree.iterparse( *name of the xml file*, events=('start', 'end'))
for event, elem in content:
if elem.tag == 'distance':
print elem.text
Hope it will work..................
On Mon, Aug 1, 2011 at 1:43 PM, Anand Balachandran Pillai <
abpillai at gmail.com> wrote:
> On Mon, Aug 1, 2011 at 1:25 PM, Kiran Jonnalagadda <jace at pobox.com> wrote:
>
> > On 31-Jul-2011, at 11:33 PM, Venkatraman S wrote:
> >
> > > A regex is the simplest IMHO, because you need not know the syntax of
> the
> > > minidom parser.
> > > But, again i have seen this quiet often that lack of knowledge of
> regexp
> > has
> > > led people to other solutions (the grapes are sour!)
> >
> > In the eternal words of Jamie Zawinski:
> >
> > """
> > Some people, when confronted with a problem, think
> > “I know, I'll use regular expressions.” Now they have two problems.
> > """
> >
> > http://regex.info/blog/2006-09-15/247
> >
>
> I had fun reading the following "quotes" :)
>
> “Give a man a regular expression and he’ll match a string…
> teach him to make his own regular expressions and you’ve got a man with
> problems.”
> –me_da_clever_one
>
> “Give a man a regular expression and he’ll match a string… but by teaching
> him how to create them, you’ve given him enough rope to hang himself” –
> Andy
> Hood
>
>
> >
> > Please resist the temptation to use regexps for XML, for down that path
> > lies only pain. It always starts with "oh, only one token? Let me use a
> > regex and get done with it," and soon enough you have a little forest of
> > random-looking characters.
> >
>
> Using regular expression to parse XML converts what is inherently
> hierarchical data to linear, flat data. Therein lies all its problems.
>
>
> >
> > Kiran
> >
> > --
> > Kiran Jonnalagadda
> > http://jace.zaiki.in/
> > http://hasgeek.in/
> >
> >
> > _______________________________________________
> > BangPypers mailing list
> > BangPypers at python.org
> > http://mail.python.org/mailman/listinfo/bangpypers
> >
>
>
>
> --
> --Anand
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
More information about the BangPypers
mailing list