# parseKMLrestaurants.py
# Purpose: Print kml placemark names and descriptions.
import bs4

baseDir = 'C:/gispy/'
fileName = baseDir + 'data/ch20/restaurants.kml'

# Get the KML soup.
with open(fileName, 'r') as kmlCode:
    soup = bs4.BeautifulSoup(kmlCode,features="html5lib")

# Print the names and descriptions.
names = soup.findAll('name')
descriptions = soup.findAll('description')
for name, description in zip(names, descriptions):
    print(name.contents[0])
    print('\t{0}'.format(description.contents))