title: Parsing KML file using pyKML
body: <p>I'm learning how to parse KML files in Python using the pyKML module. The specific file I'm using can be found <a href="https://developers.google.com/kml/documentation/extendeddata?hl=fr" rel="nofollow noreferrer">here</a> and I've also added it at the bottom of this post. I have saved the file on my computer and name it <code>test.kml</code>.</p>
  
  <p>After some research, I managed to extract a specific portion of the <code>test.kml</code> file and save the result to a DataFrame. Here's my code: </p>
  
  <pre><code>from pykml import parser
  import pandas as pd
  
  filename = 'test.kml'
  with open(filename) as fobj:
      folder = parser.parse(fobj).getroot().Document
  
  plnm = []
  
  for pm in folder.Placemark:
      plnm1 = pm.name
      plnm.append(plnm1.text)
  
  df = pd.DataFrame()
  df['name'] = plnm
  
  print(df)
            name
  0   Club house
  1  By the lake
  </code></pre>
  
  <p>I would like to add a new column to my DataFrame corresponding to the value of the <code>"holeNumber"</code>. I have tried to add the following lines in my <code>for</code> loop but without success. </p>
  
  <pre><code>for pm in folder.Placemark:
      plnm1 = pm.name
      val1 = pm.ExtendedData.holeNumber.value
      plnm.append(plnm1.text)
      val.append(val1.text)
  </code></pre>
  
  <p>I'm not sure how to access the value from that specific node. The resulting DataFrame I'm looking for is the following: </p>
  
  <pre><code>| name        | holeNumber |
  |-------------|------------|
  | Club house  | 1          |
  | By the lake | 5          |
  </code></pre>
  
  <p>Any help would be appreciated. </p>
  
  <pre><code>&lt;kml xmlns="http://www.opengis.net/kml/2.2"&gt;
  &lt;Document&gt;
    &lt;name&gt;My Golf Course Example&lt;/name&gt;
    &lt;Placemark&gt;
      &lt;name&gt;Club house&lt;/name&gt;
      &lt;ExtendedData&gt;
        &lt;Data name="holeNumber"&gt;
          &lt;value&gt;1&lt;/value&gt;
        &lt;/Data&gt;
        &lt;Data name="holeYardage"&gt;
          &lt;value&gt;234&lt;/value&gt;
        &lt;/Data&gt;
        &lt;Data name="holePar"&gt;
          &lt;value&gt;4&lt;/value&gt;
        &lt;/Data&gt;
      &lt;/ExtendedData&gt;
      &lt;Point&gt;
        &lt;coordinates&gt;-111.956,33.5043&lt;/coordinates&gt;
      &lt;/Point&gt;
    &lt;/Placemark&gt;
    &lt;Placemark&gt;
      &lt;name&gt;By the lake&lt;/name&gt;
      &lt;ExtendedData&gt;
        &lt;Data name="holeNumber"&gt;
          &lt;value&gt;5&lt;/value&gt;
        &lt;/Data&gt;
        &lt;Data name="holeYardage"&gt;
          &lt;value&gt;523&lt;/value&gt;
        &lt;/Data&gt;
        &lt;Data name="holePar"&gt;
          &lt;value&gt;5&lt;/value&gt;
        &lt;/Data&gt;
      &lt;/ExtendedData&gt;
      &lt;Point&gt;
        &lt;coordinates&gt;-111.95,33.5024&lt;/coordinates&gt;
      &lt;/Point&gt;
    &lt;/Placemark&gt;
  &lt;/Document&gt;
  &lt;/kml&gt;
  </code></pre>