"""
Search the specifed xml node for elements that match the
specified xpath query.
- Returns a list of objectes instanced by the specfied element_class.
+ Returns a list of objects instanced by the specified element_class.
"""
if not element_class:
element_class = Element
- if not fields:
- fields = element_class.fields.keys()
+ if not fields and hasattr(element_class, 'fields'):
+ fields = element_class.fields
elems = xml.xpath(xpath)
objs = []
for elem in elems:
if field in elem.attrib:
obj[field] = elem.attrib[field]
objs.append(obj)
- generic_elems = [element_class(elem.attrib, elem) for elem in elems]
return objs
-
@staticmethod
def add_elements(xml, name, objs, fields=None):
"""