X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2Fxml.py;h=d880ed3c69ea8cb70d74483ce3d346b370eea53e;hb=0d99aeaefbb5c67e963659f1c21e755cb5bc8c43;hp=89eef9e00aeb577711c64212ff48c2ca5a36ec43;hpb=becde8484a5149f51d0ab3801fa953568393464d;p=sfa.git diff --git a/sfa/util/xml.py b/sfa/util/xml.py index 89eef9e0..d880ed3c 100755 --- a/sfa/util/xml.py +++ b/sfa/util/xml.py @@ -226,7 +226,24 @@ class XML: if child.tag not in d: d[child.tag] = [] d[child.tag].append(self.todict(child)) - return d + return d + + # XXX smbaker, for record.load_from_string + def todict2(self, elem=None): + if elem is None: + elem = self.root + d = {} + d.update(elem.attrib) + d['text'] = elem.text + for child in elem.iterchildren(): + if child.tag not in d: + d[child.tag] = [] + d[child.tag].append(self.todict2(child)) + + if len(d)==1 and ("text" in d): + d = d["text"] + + return d def save(self, filename): f = open(filename, 'w')