I want to work with open data, the xml is stored here:
with help from this forum i wrote the code
from lxml import etree
from urllib.request import urlopen
root = etree.parse(urlopen(url)).getroot()
ns = { 'd': 'http://datex2.eu/schema/2/2_0' }
parking_area = root.xpath('//d:parkingAreaStatus', namespaces=ns)
parking_facility = root.xpath('//d:parkingFacilityStatus', namespaces=ns)
for pa in parking_area:
area_ref = pa.find('d:parkingAreaReference', ns)
ParkingspaceList.append(str((area_ref.get('id'))))
for pf in parking_facility:
facility_ref = pf.find('d:parkingFacilityReference', ns)
ParkingspaceList.append(str((facility_ref.get('id'))))
It seems like this works for "pa" but for "pf" i got a failure message:
ParkingspaceList.append(str((facility_ref.get('id')))) AttributeError: 'NoneType' object has no attribute 'get'
Any Tips?
best regards
TR