bugfix (aka oops, my bad)
[sfa.git] / sfa / util / xml.py
index 0ef71d9..8111050 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/python 
+from types import StringTypes
 from lxml import etree
 from StringIO import StringIO
 
@@ -101,8 +102,9 @@ class XML:
         # element.attrib.update will explode if DateTimes are in the
         # dcitionary.
         d=d.copy()
+        # looks like iteritems won't stand side-effects
         for k in d.keys():
-            if (type(d[k]) != str) and (type(d[k]) != unicode):
+            if not isinstance(d[k],StringTypes):
                 del d[k]
 
         element.attrib.update(d)
@@ -136,7 +138,7 @@ class XML:
 
     def add_element(self, name, attrs={}, parent=None, text=""):
         """
-        Generic wrapper around etree.SubElement(). Adds an element to 
+        Wrapper around etree.SubElement(). Adds an element to 
         specified parent node. Adds element to root node is parent is 
         not specified. 
         """
@@ -226,7 +228,7 @@ class XML:
         for child in elem.iterchildren():
             if child.tag not in d:
                 d[child.tag] = []
-            d[child.tag].append(self.todict2(child))
+            d[child.tag].append(self.todict(child))
 
         if len(d)==1 and ("text" in d):
             d = d["text"]