added recursive argument to get_attributes()
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 30 Jun 2011 04:56:21 +0000 (00:56 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Thu, 30 Jun 2011 04:56:21 +0000 (00:56 -0400)
sfa/rspecs/elements/element.py

index 495ff3e..898706e 100644 (file)
@@ -66,8 +66,11 @@ class Element:
         attrs['text'] = str(elem.text).strip()
         if recursive:
             for child_elem in list(elem):
-                attrs[str(child_elem.tag)] = self.get_attributes(child_elem, recursive)
-             
+                key = str(child_elem.tag)
+                if key not in attrs:
+                    attrs[key] = [self.get_attributes(child_elem, recursive)]
+                else:
+                    attrs[key].append(self.get_attributes(child_elem, recursive))
         return attrs
     
     def attributes_list(self, elem):