Jelajahi Sumber

add parse_prestashop_xml_products

sxoinas12 2 tahun lalu
induk
melakukan
f9c6a1991f
1 mengubah file dengan 12 tambahan dan 0 penghapusan
  1. 12 0
      telecaster/telecaster/parsers/parse_xml_to_json.py

+ 12 - 0
telecaster/telecaster/parsers/parse_xml_to_json.py

@@ -8,3 +8,15 @@ def parse_xml_to_json(xml):
             response[child.tag] = child.text or ''
 
     return response
+
+
+def parse_prestashop_xml_products(xml):
+    response = {}
+
+    for child in list(xml):
+        if len(list(child)) > 0:
+            response[child.attrib.get('id')] = parse_prestashop_xml_products(child)
+        else:
+            response[child.attrib.get('id')] = child.attrib
+
+    return response