0

I need to select an element base on its tag name. So i used (python and lxml) and did this:

doc.getroot().xpath("//SimpleData")

But it always return [].

When i do this however:

doc.getroot().xpath("//*")

I get a long list of results, one of which is this:

Element {http://www.opengis.net/kml/2.2}SimpleData at 0x7ff548098c88

So I would like to know what am I doing wrong? Why isnt xpath returning the SimpleData elements?

Thanks in advance.

Jenia Ivanov
  • 2,485
  • 3
  • 41
  • 69
  • 1
    You need to handle namespaces, see http://stackoverflow.com/questions/4255277/lxml-etree-xmlparser-namespace-problem. – alecxe Jul 21 '14 at 19:02
  • Damn, meant to use [Parse large XML with lxml](http://stackoverflow.com/q/16565995) instead, but I fumbled the duplicate UI. Ubuntu's answer is better still, someone reopen and re-close as dupe of [lxml etree xmlparser namespace problem](http://stackoverflow.com/q/4255277) – Martijn Pieters Jul 21 '14 at 19:19

0 Answers0