[BangPypers] parsing xml

2011-07-28 Thread Kenneth Gonsalves
hi, here is a simplified version of an xml file: ?xml version=1.0 encoding=UTF-8? gpx metadata author nameCloudMade/name email id=support domain=cloudmade.com / link href=http://maps.cloudmade.com;/link

Re: [BangPypers] parsing xml

2011-07-28 Thread Venkatraman S
grep or regexp? -V ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers

Re: [BangPypers] parsing xml

2011-07-28 Thread hemant
Using xpath such as: /gpx/extensions/distance(:text) ? On Thu, Jul 28, 2011 at 3:20 PM, Venkatraman S venka...@gmail.com wrote: grep or regexp? -V ___ BangPypers mailing list BangPypers@python.org

Re: [BangPypers] parsing xml

2011-07-28 Thread Ramdas S
On Thu, Jul 28, 2011 at 3:20 PM, Venkatraman S venka...@gmail.com wrote: grep or regexp? -V ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers can write an Xml parsing query -- Ramdas S +91

Re: [BangPypers] parsing xml

2011-07-28 Thread Anand Chitipothu
2011/7/28 Kenneth Gonsalves law...@gmail.com: hi, here is a simplified version of an xml file: ?xml version=1.0 encoding=UTF-8?    gpx        metadata                author                nameCloudMade/name                email id=support domain=cloudmade.com /                link

Re: [BangPypers] parsing xml

2011-07-28 Thread Baishampayan Ghose
here is a simplified version of an xml file: ?xml version=1.0 encoding=UTF-8?    gpx        metadata                author                nameCloudMade/name                email id=support domain=cloudmade.com /                link href=http://maps.cloudmade.com;/link                

Re: [BangPypers] parsing xml

2011-07-28 Thread Kenneth Gonsalves
On Thu, 2011-07-28 at 15:33 +0530, Anand Chitipothu wrote: I want to get the value of the distance element - 1489. What is the simplest way of doing this? from xml.dom import minidom dom = minidom.parseString(x) dom.getElementsByTagName(distance)[0].childNodes[0].nodeValue u'1489'

Re: [BangPypers] parsing xml

2011-07-28 Thread kracekumar ramaraju
You can try beautifulsoup, recommended for python/XML Parsing. ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers

Re: [BangPypers] parsing xml

2011-07-28 Thread Sidu Ponnappa
If you're doing this repeatedly, you may want to just delegate to a native XPath implementation. I haven't done much Python, so I can't comment on your choices, but in Ruby I'd simply hand off to libXML using Nokogiri. This approach should be a whole lot faster, but I'd advise benchmarking first

Re: [BangPypers] parsing xml

2011-07-28 Thread Venkatraman S
parsing using minidom is one of the slowest. if you just want to extract the distance and assuming that it(the tag) will always be consistent, then i would always suggest regexp. xml parsing is a pain. ___ BangPypers mailing list BangPypers@python.org

Re: [BangPypers] parsing xml

2011-07-28 Thread Gora Mohanty
On Thu, Jul 28, 2011 at 10:37 PM, Venkatraman S venka...@gmail.com wrote: parsing using minidom is one of the slowest. if you just want to extract the distance and assuming that it(the tag) will always be consistent, then i would always suggest regexp. xml parsing is a pain. [...] Strongly

Re: [BangPypers] parsing xml

2011-07-28 Thread Ramdas S
On Fri, Jul 29, 2011 at 1:23 AM, Gora Mohanty g...@mimirtech.com wrote: On Thu, Jul 28, 2011 at 10:37 PM, Venkatraman S venka...@gmail.com wrote: parsing using minidom is one of the slowest. if you just want to extract the distance and assuming that it(the tag) will always be consistent,

Re: [BangPypers] parsing xml

2011-07-28 Thread Joseph Gladson
Hi, check and try pyparsing module... U could do it so simple:) regards, joseph On 7/29/11, Ramdas S ram...@gmail.com wrote: On Fri, Jul 29, 2011 at 1:23 AM, Gora Mohanty g...@mimirtech.com wrote: On Thu, Jul 28, 2011 at 10:37 PM, Venkatraman S venka...@gmail.com wrote: parsing using

Re: [BangPypers] parsing xml

2011-07-28 Thread Anand Chitipothu
2011/7/28 Venkatraman S venka...@gmail.com: parsing using minidom is one of the slowest. if you just want to extract the distance and assuming that it(the tag) will always be consistent, then i would always suggest regexp. xml parsing is a pain. regexp is a bad solution to parse xml. minidom

Re: [BangPypers] parsing xml

2011-07-28 Thread Baishampayan Ghose
minidom is the fastest solution if you consider the programmer time instead of developer time.  Minidom is available in standard library, you don't have to add another dependency and worry about PyPI downtimes and lxml compilations failures. FWIW, ElementTree is a part of the standard library

Re: [BangPypers] parsing xml

2011-07-28 Thread Venkatraman S
On Fri, Jul 29, 2011 at 10:47 AM, Anand Chitipothu anandol...@gmail.comwrote: 2011/7/28 Venkatraman S venka...@gmail.com: parsing using minidom is one of the slowest. if you just want to extract the distance and assuming that it(the tag) will always be consistent, then i would always

Re: [BangPypers] parsing xml

2011-07-28 Thread Anand Chitipothu
2011/7/29 Venkatraman S venka...@gmail.com: On Fri, Jul 29, 2011 at 10:47 AM, Anand Chitipothu anandol...@gmail.comwrote: 2011/7/28 Venkatraman S venka...@gmail.com: parsing using minidom is one of the slowest. if you just want to extract the distance and assuming that it(the tag) will

Re: [BangPypers] parsing xml

2011-07-28 Thread Anand Chitipothu
2011/7/29 Baishampayan Ghose b.gh...@gmail.com: minidom is the fastest solution if you consider the programmer time instead of developer time.  Minidom is available in standard library, you don't have to add another dependency and worry about PyPI downtimes and lxml compilations failures.