Skip to content

Instantly share code, notes, and snippets.

@simos
Created April 8, 2015 09:24
Show Gist options
  • Save simos/011ac5a3e7f70397f3af to your computer and use it in GitHub Desktop.
Save simos/011ac5a3e7f70397f3af to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
FILENAME="Lesvos Birdings map of birding sites-Steve Dudley.gpx"
from lxml import etree
tree = etree.parse(FILENAME)
root = tree.getroot()
for wpt in tree.xpath('//wpt'):
name = None
desc = None
cmt = None
for child in wpt:
if (child.tag == 'name'):
name = child
elif (child.tag == 'desc'):
desc = child
elif (child.tag == 'cmt'):
cmt = child
name.text += ': '
name.text += desc.text
print (etree.tostring(root, pretty_print=True))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment