0

I'd like to make some xpath queries over abstract elements on the KML schema (like //AbstractFeatureType on a kml file).

I'm a noob in python and that make the research and trial quite painful, has anybody crossed the path of this beast during their developing hours?

Thanks,

Nico.

2
  • Could you post your current code? And are you just trying to get the elements with type="kml:AbstractFeatureType"? Commented Aug 4, 2011 at 7:15
  • This question is a bit old and in the end I didn't parse KML in my project, so there is no code anymore. But yes, I was trying to get the elements with type "kml:AbstractFeatureType", which means "kml:Placemark", "kml:NetworkLink" for instance. Commented Aug 5, 2011 at 9:13

1 Answer 1

1

This is just an attempt using the page you provided. My code returns a list of elements who have tagtype==attrib. s is a string with your xml/kml.

import lxml.etree as etree
def find(s,attrib,tagtype='*'):
    tree = etree.fromstring(s)
    return tree.xpath(r'.//%s[@*="%s"]'%(tagtype,attrib))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.