Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7646611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:15:13+00:00 2026-05-31T10:15:13+00:00

Problem: can’t find element with ‘:’ – cannot run program. I found some references

  • 0

Problem: can’t find element with ‘:’ – cannot run program. I found some references about Qualified Names but I don’t know how to apply those.

Code:

#!/usr/bin/env python
from xml.etree.ElementTree import ElementTree                           

kmlTree = ElementTree()                                                 
kmlTree.parse("data/history-03-08-2012.kml")                            

track = kmlTree.find(".//{http://www.opengis.net/kml/2.2}gx:Track")

Sample data file:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<gx:Track>
<when>2012-03-10T05:52:38.564-08:00</when>
<gx:coord>16.424247 48.236804 0</gx:coord>
<when>2012-03-10T06:00:39.748-08:00</when>
<gx:coord>16.424247 48.236804 0</gx:coord>
</gx:Track>
</kml>

Error:

Traceback (most recent call last):
  File "main.py", line 7, in <module>
    track = kmlTree.find(".//{http://www.opengis.net/kml/2.2}gx:Track")        #most interesting data is stored in this tag
  File "/usr/lib/python2.6/xml/etree/ElementTree.py", line 614, in find
    return self._root.find(path)
  File "/usr/lib/python2.6/xml/etree/ElementTree.py", line 330, in find
    return ElementPath.find(self, path)
  File "/usr/lib/python2.6/xml/etree/ElementPath.py", line 186, in find
    return _compile(path).find(element)
  File "/usr/lib/python2.6/xml/etree/ElementPath.py", line 176, in _compile
    p = Path(path)
  File "/usr/lib/python2.6/xml/etree/ElementPath.py", line 93, in __init__
    "expected path separator (%s)" % (op or tag)
SyntaxError: expected path separator (:)

Code is working for elements without ‘:’

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:15:14+00:00Added an answer on May 31, 2026 at 10:15 am

    gx is a namespace shortcut for {http://www.google.com/kml/ext/2.2}. Take gx: out of the find and use the correct namespace:

    from xml.etree import ElementTree as et
    
    data = '''\
    <?xml version="1.0" encoding="UTF-8"?>
    <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
    <gx:Track>
    <when>2012-03-10T05:52:38.564-08:00</when>
    <gx:coord>16.424247 48.236804 0</gx:coord>
    <when>2012-03-10T06:00:39.748-08:00</when>
    <gx:coord>16.424247 48.236804 0</gx:coord>
    </gx:Track>
    </kml>
    '''
    
    kmlTree = et.fromstring(data)
    
    track = kmlTree.find(".//{http://www.google.com/kml/ext/2.2}Track")
    print(track)
    

    Output

    <Element '{http://www.google.com/kml/ext/2.2}Track' at 0x40cca70>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a problem I can't find any solution for. I have a textfile
I'm having a problem and can't seem to find the solution.. int linearSearch(nodeptr list,char
Hello! My problem can be described the following way: I have some data which
The problem can be found in the following code: def debug[T](format: String, arg1:T, arg2:Any,
Got this really stupid problem: Can find the proper name for the android folder
I have encountered some unforeseen consequences of porting to mono 2.8.1. Problem can be
I have to convert an C# code to VB.NET, but I've some problem....can you
I have some problem with PostSharp (I assume that problem can be solved by
I encountered this problem when doing some enthusiastic programming. The problem can be expressed
I'm building a database and have run into a problem that I can't seem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.