- location_objs = Element.get_elements(node_elem, './default:location | ./location', Location)
- if len(location_objs) > 0:
- node['location'] = location_objs[0]
- bwlimit_objs = Element.get_elements(node_elem, './default:bw_limit | ./bw_limit', BWlimit)
- if len(bwlimit_objs) > 0:
- node['bwlimit'] = bwlimit_objs[0]
- node['interfaces'] = Element.get_elements(node_elem, './default:interface | ./interface', Interface)
+ # get location
+ location_elems = node_elem.xpath('./default:location | ./location')
+ locations = [loc_elem.get_instance(Location) for loc_elem in location_elems]
+ if len(locations) > 0:
+ node['location'] = locations[0]
+ # get bwlimit
+ bwlimit_elems = node_elem.xpath('./default:bw_limit | ./bw_limit')
+ bwlimits = [bwlimit_elem.get_instance(BWlimit) for bwlimit_elem in bwlimit_elems]
+ if len(bwlimits) > 0:
+ node['bwlimit'] = bwlimits[0]
+ # get interfaces
+ iface_elems = node_elem.xpath('./default:interface | ./interface')
+ ifaces = [iface_elem.get_instance(Interface) for iface_elem in iface_elems]
+ node['interfaces'] = ifaces
+ # get services