title: How to parse kml file as tree structure in python?
body: <p>I have a kml file that I am trying to parse in python,what I wanted is to pass val3 from SimpleData
  as an argument,and the coordinates for only that placemark tag will be retrieved,I have worked on xpath before:
  A typical example in xpath expression would be:</p>
  
  <pre><code>value = '..'
  for val in (//Placement/ExtendedData/SimpleData[contains(text(), "+value+")]):
      print val.find_element_by_xpath(//coordinates)
  </code></pre>
  
  <p>However I can't seem to get the same by using element tree in Python:</p>
  
  <p>This is the kml file<br>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;kml xmlns="http://www.opengis.net/kml/2.2"&gt;
  &lt;Document id="root_doc"&gt;
  &lt;Schema name="" id=""&gt;
      &lt;SimpleField name="NAME_0" type="string"&gt;&lt;/SimpleField&gt;
      &lt;SimpleField name="NAME_1" type="string"&gt;&lt;/SimpleField&gt;
  &lt;/Schema&gt;
  &lt;Folder&gt;&lt;name&gt;&lt;/name&gt;
    &lt;Placemark&gt;
      &lt;Style&gt;&lt;LineStyle&gt;&lt;color&gt;ff0000ff&lt;/color&gt;&lt;/LineStyle&gt;&lt;PolyStyle&gt;&lt;fill&gt;0&lt;/fill&gt;&lt;/PolyStyle&gt;&lt;/Style&gt;
      &lt;ExtendedData&gt;&lt;SchemaData schemaUrl="#gadm36_IND_3"&gt;
          &lt;SimpleData name="NAME_0"&gt;val1&lt;/SimpleData&gt;
          &lt;SimpleData name="NAME_1"&gt;val2&lt;/SimpleData&gt;
          &lt;SimpleData name="NAME_2"&gt;val3&lt;/SimpleData&gt;
      &lt;/SchemaData&gt;&lt;/ExtendedData&gt;
        &lt;MultiGeometry&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;92.7877807617189,9.24416637420654 92.7888870239258,9.24305438995361 92.7897186279296,9.24306106567383 92.7902832031251,9.24250030517589 92.7905578613282,9.24250030517589 92.7911148071289,9.24194431304943 92.7913894653321,9.24194431304943 92.7922210693359,9.24110984802257 92.7922210693359,9.24083423614508 92.7930526733399,9.23999977111822
        &lt;/coordinates&gt;&lt;/LinearRing&gt;...
        &lt;Placemark&gt;
      &lt;Style&gt;&lt;LineStyle&gt;&lt;color&gt;ff0000ff&lt;/color&gt;&lt;/LineStyle&gt;&lt;PolyStyle&gt;&lt;fill&gt;0&lt;/fill&gt;&lt;/PolyStyle&gt;&lt;/Style&gt;
      &lt;ExtendedData&gt;&lt;SchemaData schemaUrl="#gadm36_IND_3"&gt;
          &lt;SimpleData name="NAME_0"&gt;val1&lt;/SimpleData&gt;
          &lt;SimpleData name="NAME_1"&gt;val2&lt;/SimpleData&gt;
          &lt;SimpleData name="NAME_2"&gt;val3&lt;/SimpleData&gt;
      &lt;/SchemaData&gt;&lt;/ExtendedData&gt;
        &lt;MultiGeometry&gt;&lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;92.7877807617189,9.24416637420654 92.7888870239258,9.24305438995361 92.7897186279296,9.24306106567383 92.7902832031251,9.24250030517589 92.7905578613282,9.24250030517589 92.7911148071289,9.24194431304943 92.7913894653321,9.24194431304943 92.7922210693359,9.24110984802257 92.7922210693359,9.24083423614508 92.7930526733399,9.23999977111822
        &lt;/coordinates&gt;&lt;/LinearRing&gt;...
  </code></pre>
  
  <p>This is what Im stuck on:</p>
  
  <pre><code>import xml.etree.ElementTree as ET
  tree = ET.parse('')
  root = tree.getroot()
  for val in root.findall('.//{http://www.opengis.net/kml/2.2}SimpleData[@text=""]//coordinates'):
      print val.text
  </code></pre>