Pārlūkot izejas kodu

add parse_prestashop_xml_products

sxoinas12 2 gadi atpakaļ
vecāks
revīzija
f9c6a1991f
1 mainītis faili ar 12 papildinājumiem un 0 dzēšanām
  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